Skip to content

Commit

Permalink
Use appropriate power mask for USB2 vs USB3
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
mvp committed Feb 14, 2018
1 parent 8e667cd commit fb5d521
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions uhubctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fb5d521

Please sign in to comment.