wok-current view sane-backends/stuff/xerox_mfp_fix_usb_devices.patch @ rev 18465

libQtDBus: add /usr/bin/qdbus
author Xander Ziiryanoff <psychomaniak@xakep.ru>
date Fri Oct 02 13:31:38 2015 +0200 (2015-10-02)
parents
children
line source
1 commit 5ea227caeacd504b64eef301e83fa63e0a25b3f7
2 Author: Alex Belkin <abc@telekom.ru>
3 Date: Tue Mar 8 17:57:19 2011 +0300
5 keep usb device by default (correct for bug introduced by tcp sub-backend
7 diff --git a/backend/xerox_mfp.c b/backend/xerox_mfp.c
8 index e08b50f..d4672a7 100644
9 --- a/backend/xerox_mfp.c
10 +++ b/backend/xerox_mfp.c
11 @@ -37,10 +37,10 @@
12 static const SANE_Device **devlist = NULL; /* sane_get_devices array */
13 static struct device *devices_head = NULL; /* sane_get_devices list */
15 -transport available_transports[] = {
16 +enum { TRANSPORT_USB, TRANSPORT_TCP, TRANSPORTS_MAX };
17 +transport available_transports[TRANSPORTS_MAX] = {
18 { "usb", usb_dev_request, usb_dev_open, usb_dev_close, usb_configure_device },
19 { "tcp", tcp_dev_request, tcp_dev_open, tcp_dev_close, tcp_configure_device },
20 - { 0 }
21 };
23 static int resolv_state(int state)
24 @@ -824,7 +824,13 @@ free_devices (void)
25 devices_head = NULL;
26 }
28 -/* SANE API ignores return code of this callback */
29 +static transport *tr_from_devname(SANE_String_Const devname)
30 +{
31 + if (strncmp("tcp", devname, 3) == 0)
32 + return &available_transports[TRANSPORT_TCP];
33 + return &available_transports[TRANSPORT_USB];
34 +}
35 +
36 static SANE_Status
37 list_one_device (SANE_String_Const devname)
38 {
39 @@ -839,12 +845,7 @@ list_one_device (SANE_String_Const devname)
40 return SANE_STATUS_GOOD;
41 }
43 - for (tr = available_transports; tr->ttype; tr++) {
44 - if (!strncmp (devname, tr->ttype, strlen(tr->ttype)))
45 - break;
46 - }
47 - if (!tr->ttype)
48 - return SANE_STATUS_INVAL;
49 + tr = tr_from_devname(devname);
51 dev = calloc (1, sizeof (struct device));
52 if (dev == NULL)
53 @@ -878,13 +879,7 @@ list_one_device (SANE_String_Const devname)
54 static SANE_Status
55 list_conf_devices (UNUSED (SANEI_Config * config), const char *devname)
56 {
57 - transport *tr;
58 -
59 - for (tr = available_transports; tr->ttype; tr++) {
60 - if (!strncmp (devname, tr->ttype, strlen(tr->ttype)))
61 - return tr->configure_device(devname, list_one_device);
62 - }
63 - return SANE_STATUS_INVAL;
64 + return tr_from_devname(devname)->configure_device(devname, list_one_device);
65 }
67 SANE_Status