From fb5d521290b2b7cd270d6410f0776de3b6d27e4a Mon Sep 17 00:00:00 2001 From: Vadim Mikhailov Date: Wed, 14 Feb 2018 15:52:30 -0800 Subject: 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! --- uhubctl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/uhubctl.c b/uhubctl.c index 02a5213..dd191fd 100644 --- a/uhubctl.c +++ b/uhubctl.c @@ -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, -- cgit v1.2.3