diff options
author | Vadim Mikhailov <mvp@users.noreply.github.com> | 2018-02-14 15:52:30 -0800 |
---|---|---|
committer | Vadim Mikhailov <mvp@users.noreply.github.com> | 2018-02-14 15:54:23 -0800 |
commit | fb5d521290b2b7cd270d6410f0776de3b6d27e4a (patch) | |
tree | 896257c5f819034e73df3ff38a7e54d0acf2d260 | |
parent | 8e667cde10fe9d5aece33a8fadba453315cc2d03 (diff) |
Use appropriate power mask for USB2 vs USB3
USB3 should use USB_SS_PORT_STAT_POWER,
which is different from USB2 value USB_PORT_STAT_POWER.
Thanks to Stanislas Bertrand for spotting this bug!
-rw-r--r-- | uhubctl.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -746,14 +746,16 @@ int main(int argc, char *argv[]) for (port=1; port <= hubs[i].nports; port++) { if ((1 << (port-1)) & ports) { int port_status = get_port_status(devh, port); - if (k == 0 && !(port_status & USB_PORT_STAT_POWER)) + int power_mask = (hubs[i].bcd_usb < 0x300) ? USB_PORT_STAT_POWER + : USB_SS_PORT_STAT_POWER; + if (k == 0 && !(port_status & power_mask)) continue; - if (k == 1 && (port_status & USB_PORT_STAT_POWER)) + if (k == 1 && (port_status & power_mask)) continue; int repeat = 1; if (k == 0) repeat = opt_repeat; - if (!(port_status & ~USB_PORT_STAT_POWER)) + if (!(port_status & ~power_mask)) repeat = 1; while (repeat-- > 0) { rc = libusb_control_transfer(devh, |