diff options
author | Nikias Bassen | 2009-08-20 00:11:25 +0200 |
---|---|---|
committer | Hector Martin | 2009-08-21 02:44:25 +0200 |
commit | 3c19d124c7521aeef6e4f28755c649a58c2860b6 (patch) | |
tree | ed99fd0a4e17b2e69fcf4c67f302fe39f4a6c82d /usbmuxd | |
parent | 1a0c58e4062da7db73b4c08963f741cf016f6aa5 (diff) | |
download | usbmuxd-3c19d124c7521aeef6e4f28755c649a58c2860b6.tar.gz usbmuxd-3c19d124c7521aeef6e4f28755c649a58c2860b6.tar.bz2 |
Only try to set configuration if needed.
Diffstat (limited to 'usbmuxd')
-rw-r--r-- | usbmuxd/usb-linux.c | 12 | ||||
-rw-r--r-- | usbmuxd/usb.h | 1 |
2 files changed, 10 insertions, 3 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, ¤t_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); diff --git a/usbmuxd/usb.h b/usbmuxd/usb.h index d13d9ba..621ccb2 100644 --- a/usbmuxd/usb.h +++ b/usbmuxd/usb.h @@ -48,7 +48,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define PID_ITOUCH2G 0x1293 #define PID_IPHONE3GS 0x1294 -#define USB_CONFIGURATION 3 #define USB_INTERFACE 1 struct usb_device; |