diff options
| author | 2009-08-20 00:11:25 +0200 | |
|---|---|---|
| committer | 2009-08-21 02:44:25 +0200 | |
| commit | 3c19d124c7521aeef6e4f28755c649a58c2860b6 (patch) | |
| tree | ed99fd0a4e17b2e69fcf4c67f302fe39f4a6c82d | |
| parent | 1a0c58e4062da7db73b4c08963f741cf016f6aa5 (diff) | |
| download | usbmuxd-3c19d124c7521aeef6e4f28755c649a58c2860b6.tar.gz usbmuxd-3c19d124c7521aeef6e4f28755c649a58c2860b6.tar.bz2 | |
Only try to set configuration if needed.
| -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) | |||
| 279 | usbmuxd_log(LL_WARNING, "Could not open device %d-%d: %d", bus, address, res); | 279 | usbmuxd_log(LL_WARNING, "Could not open device %d-%d: %d", bus, address, res); |
| 280 | continue; | 280 | continue; |
| 281 | } | 281 | } |
| 282 | if((res = libusb_set_configuration(handle, USB_CONFIGURATION)) != 0) { | 282 | int current_config = 0; |
| 283 | usbmuxd_log(LL_WARNING, "Could not set configuration %d for device %d-%d: %d", USB_CONFIGURATION, bus, address, res); | 283 | if((res = libusb_get_configuration(handle, ¤t_config)) != 0) { |
| 284 | usbmuxd_log(LL_WARNING, "Could not get configuration for device %d-%d: %d", bus, address, res); | ||
| 284 | libusb_close(handle); | 285 | libusb_close(handle); |
| 285 | continue; | 286 | continue; |
| 286 | } | 287 | } |
| 288 | if (current_config != devdesc.bNumConfigurations) { | ||
| 289 | 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); | ||
| 291 | libusb_close(handle); | ||
| 292 | continue; | ||
| 293 | } | ||
| 294 | } | ||
| 287 | if((res = libusb_claim_interface(handle, USB_INTERFACE)) != 0) { | 295 | if((res = libusb_claim_interface(handle, USB_INTERFACE)) != 0) { |
| 288 | usbmuxd_log(LL_WARNING, "Could not claim interface %d for device %d-%d: %d", USB_INTERFACE, bus, address, res); | 296 | usbmuxd_log(LL_WARNING, "Could not claim interface %d for device %d-%d: %d", USB_INTERFACE, bus, address, res); |
| 289 | libusb_close(handle); | 297 | 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 | |||
| 48 | #define PID_ITOUCH2G 0x1293 | 48 | #define PID_ITOUCH2G 0x1293 |
| 49 | #define PID_IPHONE3GS 0x1294 | 49 | #define PID_IPHONE3GS 0x1294 |
| 50 | 50 | ||
| 51 | #define USB_CONFIGURATION 3 | ||
| 52 | #define USB_INTERFACE 1 | 51 | #define USB_INTERFACE 1 |
| 53 | 52 | ||
| 54 | struct usb_device; | 53 | struct usb_device; |
