summaryrefslogtreecommitdiffstats
path: root/usbmuxd/usb-linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'usbmuxd/usb-linux.c')
-rw-r--r--usbmuxd/usb-linux.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usbmuxd/usb-linux.c b/usbmuxd/usb-linux.c
index 6e99a95..9634d14 100644
--- a/usbmuxd/usb-linux.c
+++ b/usbmuxd/usb-linux.c
@@ -279,11 +279,19 @@ static int usb_discover(void)
usbmuxd_log(LL_WARNING, "Could not open device %d-%d: %d", bus, address, res);
continue;
}
- if((res = libusb_set_configuration(handle, USB_CONFIGURATION)) != 0) {
- usbmuxd_log(LL_WARNING, "Could not set configuration %d for device %d-%d: %d", USB_CONFIGURATION, bus, address, res);
+ int current_config = 0;
+ if((res = libusb_get_configuration(handle, &current_config)) != 0) {
+ usbmuxd_log(LL_WARNING, "Could not get configuration for device %d-%d: %d", bus, address, res);
libusb_close(handle);
continue;
}
+ if (current_config != devdesc.bNumConfigurations) {
+ if((res = libusb_set_configuration(handle, devdesc.bNumConfigurations)) != 0) {
+ usbmuxd_log(LL_WARNING, "Could not set configuration %d for device %d-%d: %d", devdesc.bNumConfigurations, bus, address, res);
+ libusb_close(handle);
+ continue;
+ }
+ }
if((res = libusb_claim_interface(handle, USB_INTERFACE)) != 0) {
usbmuxd_log(LL_WARNING, "Could not claim interface %d for device %d-%d: %d", USB_INTERFACE, bus, address, res);
libusb_close(handle);