diff options
| -rw-r--r-- | daemon/usb-linux.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/daemon/usb-linux.c b/daemon/usb-linux.c index cc1bbaf..c9420c8 100644 --- a/daemon/usb-linux.c +++ b/daemon/usb-linux.c | |||
| @@ -286,6 +286,26 @@ int usb_discover(void) | |||
| 286 | continue; | 286 | continue; |
| 287 | } | 287 | } |
| 288 | if (current_config != devdesc.bNumConfigurations) { | 288 | if (current_config != devdesc.bNumConfigurations) { |
| 289 | struct libusb_config_descriptor *config; | ||
| 290 | if((res = libusb_get_active_config_descriptor(dev, &config)) != 0) { | ||
| 291 | usbmuxd_log(LL_NOTICE, "Could not get old configuration descriptor for device %d-%d: %d", bus, address, res); | ||
| 292 | } else { | ||
| 293 | for(j=0; j<config->bNumInterfaces; j++) { | ||
| 294 | const struct libusb_interface_descriptor *intf = &config->interface[j].altsetting[0]; | ||
| 295 | if((res = libusb_kernel_driver_active(handle, intf->bInterfaceNumber)) < 0) { | ||
| 296 | usbmuxd_log(LL_NOTICE, "Could not check kernel ownership of interface %d for device %d-%d: %d", intf->bInterfaceNumber, bus, address, res); | ||
| 297 | continue; | ||
| 298 | } | ||
| 299 | if(res == 1) { | ||
| 300 | usbmuxd_log(LL_INFO, "Detaching kernel driver for device %d-%d, interface %d", bus, address, intf->bInterfaceNumber); | ||
| 301 | if((res = libusb_detach_kernel_driver(handle, intf->bInterfaceNumber)) < 0) { | ||
| 302 | usbmuxd_log(LL_WARNING, "Could not detach kernel driver (%d), configuration change will probably fail!", res); | ||
| 303 | continue; | ||
| 304 | } | ||
| 305 | } | ||
| 306 | } | ||
| 307 | libusb_free_config_descriptor(config); | ||
| 308 | } | ||
| 289 | if((res = libusb_set_configuration(handle, devdesc.bNumConfigurations)) != 0) { | 309 | if((res = libusb_set_configuration(handle, devdesc.bNumConfigurations)) != 0) { |
| 290 | usbmuxd_log(LL_WARNING, "Could not set configuration %d for device %d-%d: %d", devdesc.bNumConfigurations, bus, address, res); | 310 | usbmuxd_log(LL_WARNING, "Could not set configuration %d for device %d-%d: %d", devdesc.bNumConfigurations, bus, address, res); |
| 291 | libusb_close(handle); | 311 | libusb_close(handle); |
