summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Hjelm <hjelmn@mac.com>2010-03-23 16:22:08 -0600
committerDaniel Drake <dan@reactivated.net>2010-03-23 16:22:08 -0600
commitec303b01a5d4e51c000a283853af65059fa62285 (patch)
tree42a801389c773f1fd5abf33bf815f791c3cd80e7
parentcd809e2f7cee3874b7ae16b2c482a8b63a90e4a5 (diff)
downloadlibusb-ec303b01a5d4e51c000a283853af65059fa62285.tar.gz
Darwin: fix enumeration of devices with non-consecutive addresses (#23)
-rw-r--r--libusb/os/darwin_usb.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index 8e35c06..63e25e0 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -155,18 +155,22 @@ static usb_device_t **usb_get_next_device (io_iterator_t deviceIterator, UInt32
long result;
SInt32 score;
- if (!IOIteratorIsValid (deviceIterator) || !(usbDevice = IOIteratorNext(deviceIterator)))
+ if (!IOIteratorIsValid (deviceIterator))
return NULL;
-
- result = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID,
- kIOCFPlugInInterfaceID, &plugInInterface,
- &score);
-
- if (result || !plugInInterface) {
+
+
+ while ((usbDevice = IOIteratorNext(deviceIterator))) {
+ result = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID,
+ kIOCFPlugInInterfaceID, &plugInInterface,
+ &score);
+ if (kIOReturnSuccess == result && plugInInterface)
+ break;
+
usbi_dbg ("libusb/darwin.c usb_get_next_device: could not set up plugin for service: %s\n", darwin_error_str (result));
+ }
+ if (!usbDevice)
return NULL;
- }
(void)IOObjectRelease(usbDevice);
(void)(*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(DeviceInterfaceID),