fix detection/handling of USB devices in xerox_mfp (#702983)

This commit is contained in:
Nils Philippsen 2011-05-10 10:25:49 +02:00
parent c61644cd90
commit 07f2601761
2 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,81 @@
From 9792fb4ac11443553771d4f311a985333b503594 Mon Sep 17 00:00:00 2001
From: Nils Philippsen <nils@redhat.com>
Date: Tue, 10 May 2011 10:22:02 +0200
Subject: [PATCH] patch: xerox_mfp-fix-usb-devices
Squashed commit of the following:
commit 962a5a657b750f99b274d58763667bd199f5cb5d
Author: Alex Belkin <abc@telekom.ru>
Date: Tue Mar 8 17:57:19 2011 +0300
keep usb device by default (correct for bug introduced by tcp sub-backend
(cherry picked from commit 5ea227caeacd504b64eef301e83fa63e0a25b3f7)
---
backend/xerox_mfp.c | 27 +++++++++++----------------
1 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/backend/xerox_mfp.c b/backend/xerox_mfp.c
index e08b50f..d4672a7 100644
--- a/backend/xerox_mfp.c
+++ b/backend/xerox_mfp.c
@@ -37,10 +37,10 @@
static const SANE_Device **devlist = NULL; /* sane_get_devices array */
static struct device *devices_head = NULL; /* sane_get_devices list */
-transport available_transports[] = {
+enum { TRANSPORT_USB, TRANSPORT_TCP, TRANSPORTS_MAX };
+transport available_transports[TRANSPORTS_MAX] = {
{ "usb", usb_dev_request, usb_dev_open, usb_dev_close, usb_configure_device },
{ "tcp", tcp_dev_request, tcp_dev_open, tcp_dev_close, tcp_configure_device },
- { 0 }
};
static int resolv_state(int state)
@@ -824,7 +824,13 @@ free_devices (void)
devices_head = NULL;
}
-/* SANE API ignores return code of this callback */
+static transport *tr_from_devname(SANE_String_Const devname)
+{
+ if (strncmp("tcp", devname, 3) == 0)
+ return &available_transports[TRANSPORT_TCP];
+ return &available_transports[TRANSPORT_USB];
+}
+
static SANE_Status
list_one_device (SANE_String_Const devname)
{
@@ -839,12 +845,7 @@ list_one_device (SANE_String_Const devname)
return SANE_STATUS_GOOD;
}
- for (tr = available_transports; tr->ttype; tr++) {
- if (!strncmp (devname, tr->ttype, strlen(tr->ttype)))
- break;
- }
- if (!tr->ttype)
- return SANE_STATUS_INVAL;
+ tr = tr_from_devname(devname);
dev = calloc (1, sizeof (struct device));
if (dev == NULL)
@@ -878,13 +879,7 @@ list_one_device (SANE_String_Const devname)
static SANE_Status
list_conf_devices (UNUSED (SANEI_Config * config), const char *devname)
{
- transport *tr;
-
- for (tr = available_transports; tr->ttype; tr++) {
- if (!strncmp (devname, tr->ttype, strlen(tr->ttype)))
- return tr->configure_device(devname, list_one_device);
- }
- return SANE_STATUS_INVAL;
+ return tr_from_devname(devname)->configure_device(devname, list_one_device);
}
SANE_Status
--
1.7.5.1

View File

@ -1,7 +1,7 @@
Summary: Scanner access software Summary: Scanner access software
Name: sane-backends Name: sane-backends
Version: 1.0.22 Version: 1.0.22
Release: 2%{?dist} Release: 3%{?dist}
# lib/ is LGPLv2+, backends are GPLv2+ with exceptions # lib/ is LGPLv2+, backends are GPLv2+ with exceptions
# Tools are GPLv2+, docs are public domain # Tools are GPLv2+, docs are public domain
# see LICENSE for details # see LICENSE for details
@ -23,6 +23,8 @@ Patch4: sane-backends-1.0.22-docs-utf8.patch
Patch5: sane-backends-1.0.21-SCX4500W.patch Patch5: sane-backends-1.0.21-SCX4500W.patch
# backported from upstream c5ca46c2d1be78c651afb843cc834cf2b5b24953 # backported from upstream c5ca46c2d1be78c651afb843cc834cf2b5b24953
Patch6: sane-backends-1.0.22-v4l.patch Patch6: sane-backends-1.0.22-v4l.patch
# backported from upstream 5ea227caeacd504b64eef301e83fa63e0a25b3f7
Patch7: sane-backends-1.0.22-xerox_mfp-fix-usb-devices.patch
URL: http://www.sane-project.org URL: http://www.sane-project.org
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%__id_u -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%__id_u -n)
BuildRequires: tetex-latex BuildRequires: tetex-latex
@ -90,6 +92,7 @@ want to access digital cameras.
%patch4 -p1 -b .docs-utf8 %patch4 -p1 -b .docs-utf8
%patch5 -p1 -b .SCX4500W %patch5 -p1 -b .SCX4500W
%patch6 -p1 -b .v4l %patch6 -p1 -b .v4l
%patch7 -p1 -b .xerox_mfp-fix-usb-devices
%build %build
# use PIC/PIE because SANE-enabled software is likely to deal with data coming # use PIC/PIE because SANE-enabled software is likely to deal with data coming
@ -168,6 +171,9 @@ rm -rf %{buildroot}
%{_libdir}/pkgconfig/sane-backends.pc %{_libdir}/pkgconfig/sane-backends.pc
%changelog %changelog
* Tue May 10 2011 Nils Philippsen <nils@redhat.com> - 1.0.22-3
- fix detection/handling of USB devices in xerox_mfp (#702983)
* Tue Apr 19 2011 Nils Philippsen <nils@redhat.com> - 1.0.22-2 * Tue Apr 19 2011 Nils Philippsen <nils@redhat.com> - 1.0.22-2
- remove obsolete lockdir, automake patches - remove obsolete lockdir, automake patches