diff options
author | Pete Batard <pete@akeo.ie> | 2012-07-18 18:25:11 +0100 |
---|---|---|
committer | Pete Batard <pete@akeo.ie> | 2012-07-18 18:25:11 +0100 |
commit | 8cd30bb7066f785ee78cf6c3dccafdbc4b957b50 (patch) | |
tree | 4366a25ce64f148913ae1fa3bf9a38a9ce77b888 | |
parent | e82c677b5f10a966c89f6b58caa1ae4341260527 (diff) |
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.
-rw-r--r-- | libusb/os/windows_usb.c | 7 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 6 insertions, 3 deletions
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 |