summaryrefslogtreecommitdiffstats
path: root/usbmuxd/usb-linux.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-08-20 00:11:25 +0200
committerGravatar Hector Martin2009-08-21 02:44:25 +0200
commit3c19d124c7521aeef6e4f28755c649a58c2860b6 (patch)
treeed99fd0a4e17b2e69fcf4c67f302fe39f4a6c82d /usbmuxd/usb-linux.c
parent1a0c58e4062da7db73b4c08963f741cf016f6aa5 (diff)
downloadusbmuxd-3c19d124c7521aeef6e4f28755c649a58c2860b6.tar.gz
usbmuxd-3c19d124c7521aeef6e4f28755c649a58c2860b6.tar.bz2
Only try to set configuration if needed.
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);