Set USB configuration only if there are alternative ones

This fixes USB3 issues for the epson and epson2 backends.  Both these
backends already made sure to send an even number of reads and writes
but were affected nevertheless.

It also solves USB3 issues with the third party epkowa backend.  This
one doesn't bother to ensure even counts of packets read and written.
It works fine when this fix is applied (and it no longer clears halts
w/o a stall condition).  Note, there is no need to ensure even packet
counts.
merge-requests/1/head
Olaf Meeuwissen 2014-12-02 10:03:38 +09:00 zatwierdzone przez m. allan noah
rodzic a429b8a0ed
commit 71c1a0068f
1 zmienionych plików z 56 dodań i 53 usunięć

Wyświetl plik

@ -1379,14 +1379,15 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
"configuration (%d), choosing first config (%d)\n",
dev->descriptor.bNumConfigurations,
dev->config[0].bConfigurationValue);
}
result = usb_set_configuration (devices[devcount].libusb_handle,
dev->config[0].bConfigurationValue);
if (result < 0)
{
SANE_Status status = SANE_STATUS_INVAL;
DBG (1, "sanei_usb_open: libusb complained: %s\n", usb_strerror ());
DBG (1, "sanei_usb_open: libusb complained: %s\n",
usb_strerror ());
if (errno == EPERM || errno == EACCES)
{
DBG (1, "Make sure you run as root or set appropriate "
@ -1405,6 +1406,7 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
return status;
}
}
}
/* Claim the interface */
result = usb_claim_interface (devices[devcount].libusb_handle,
@ -1670,7 +1672,7 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
"configuration (%d), choosing first config (%d)\n",
desc.bNumConfigurations,
config0->bConfigurationValue);
}
result = libusb_set_configuration (devices[devcount].lu_handle,
config0->bConfigurationValue);
@ -1690,8 +1692,8 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
}
else if (result == LIBUSB_ERROR_BUSY)
{
DBG (3, "Maybe the kernel scanner driver or usblp claims the "
"interface? Ignoring this error...\n");
DBG (3, "Maybe the kernel scanner driver or usblp claims "
"the interface? Ignoring this error...\n");
status = SANE_STATUS_GOOD;
}
@ -1701,6 +1703,7 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
return status;
}
}
}
/* Claim the interface */
result = libusb_claim_interface (devices[devcount].lu_handle,