diff options
author | Daniel Drake <dan@reactivated.net> | 2010-04-20 20:14:09 -0300 |
---|---|---|
committer | Daniel Drake <dan@reactivated.net> | 2010-04-20 20:14:09 -0300 |
commit | 1519828b7ee1fce46d4c51fc097d52e01b8e0bb4 (patch) | |
tree | 4b5a85a5a039198e46cbf78caec2fd94ea6e7ab7 | |
parent | 45168627cc15aee3875192f34286110dbbd27095 (diff) | |
download | libusb-1519828b7ee1fce46d4c51fc097d52e01b8e0bb4.tar.gz |
Linux: Handle failure to read active configuration during enumeration
-rw-r--r-- | libusb/os/linux_usbfs.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index bdd7e1d..058b736 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -646,7 +646,8 @@ static int usbfs_get_active_config(struct libusb_device *dev, int fd) if (errno == ENODEV) return LIBUSB_ERROR_NO_DEVICE; - usbi_err(DEVICE_CTX(dev), + /* we hit this error path frequently with buggy devices :( */ + usbi_warn(DEVICE_CTX(dev), "get_configuration failed ret=%d errno=%d", r, errno); return LIBUSB_ERROR_IO; } @@ -716,7 +717,13 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum, "determine active configuration descriptor", path); } else { active_config = usbfs_get_active_config(dev, fd); - if (active_config < 0) { + if (active_config == LIBUSB_ERROR_IO) { + /* buggy devices sometimes fail to report their active config. + * assume unconfigured and continue the probing */ + usbi_warn(DEVICE_CTX(dev), "couldn't query active " + "configuration, assumung unconfigured"); + device_configured = 0; + } else if (active_config < 0) { close(fd); return active_config; } else if (active_config == 0) { @@ -725,7 +732,7 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum, * not support buggy devices in these circumstances. * stick to the specs: a configuration value of 0 means * unconfigured. */ - usbi_dbg("assuming unconfigured device"); + usbi_dbg("active cfg 0? assuming unconfigured device"); device_configured = 0; } } |