From: Pete Batard Date: Wed, 18 Jul 2012 17:25:11 +0000 (+0100) Subject: Windows: Set device number for root hubs to 1 X-Git-Tag: upstream/1.0.21~611 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8cd30bb7066f785ee78cf6c3dccafdbc4b957b50;p=platform%2Fupstream%2Flibusb.git Windows: Set device number for root hubs to 1 * Other platforms (Linux, OS-X) appear to use 1 => follow suit. * For non root hub devices, we simply increment the USB device address. * Collisions with device address 0 are not expected, but we add an assertion for just in case. --- diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index 8615039..8829da4 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -1067,7 +1067,10 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d if (conn_info.DeviceAddress > UINT8_MAX) { usbi_err(ctx, "program assertion failed: device address overflow"); } - dev->device_address = (uint8_t)conn_info.DeviceAddress; + dev->device_address = (uint8_t)conn_info.DeviceAddress + 1; + if (dev->device_address == 1) { + usbi_err(ctx, "program assertion failed: device address collision with root hub"); + } switch (conn_info.Speed) { case 0: dev->speed = LIBUSB_SPEED_LOW; break; case 1: dev->speed = LIBUSB_SPEED_FULL; break; @@ -1078,7 +1081,7 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d break; } } else { - dev->device_address = UINT8_MAX; // Hubs from HCD have a devaddr of 255 + dev->device_address = 1; // root hubs are set to use device number 1 force_hcd_device_descriptor(dev); } diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 4e1e808..ec7e590 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10540 +#define LIBUSB_NANO 10541