summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-09-23 11:30:57 +0200
committerHans de Goede <hdegoede@redhat.com>2013-10-07 18:03:55 +0200
commite0d7878badb0df470669d44da001cdd7bbcc1586 (patch)
tree8005c819b7f1f7e36ff495faee24c6fb88fdf774
parent89530cef025a36c719fc5a870a8f64b5a339a1a3 (diff)
usb-host-libusb: Configuration 0 may be a valid configuration
Quoting from: linux/Documentation/ABI/stable/sysfs-bus-usb: Note that some devices, in violation of the USB spec, have a configuration with a value equal to 0. Writing 0 to bConfigurationValue for these devices will install that configuration, rather then unconfigure the device. So don't compare the configuration value against 0 to check for unconfigured devices, instead check for a LIBUSB_ERROR_NOT_FOUND return from libusb_get_active_config_descriptor(). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--hw/usb/host-libusb.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 26ebb6b28..7cbeae51e 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -992,15 +992,14 @@ static int usb_host_claim_interfaces(USBHostDevice *s, int configuration)
udev->ninterfaces = 0;
udev->configuration = 0;
- if (configuration == 0) {
- /* address state - ignore */
- return USB_RET_SUCCESS;
- }
-
usb_host_detach_kernel(s);
rc = libusb_get_active_config_descriptor(s->dev, &conf);
if (rc != 0) {
+ if (rc == LIBUSB_ERROR_NOT_FOUND) {
+ /* address state - ignore */
+ return USB_RET_SUCCESS;
+ }
return USB_RET_STALL;
}