Skip to content

Commit 2df4681

Browse files
bluecmdmvp
authored andcommitted
Construct root USB device sysfs path
Fixes #578. See issue for discussion. Signed-off-by: Christian Svensson <[email protected]>
1 parent 359d887 commit 2df4681

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

uhubctl.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,17 @@ static int set_port_status_linux(struct libusb_device_handle *devh, struct hub_i
574574
* The "disable" sysfs interface is available only starting with kernel version 6.0.
575575
* For earlier kernel versions the open() call will fail and we fall back to using libusb.
576576
*/
577-
snprintf(disable_path, PATH_MAX,
578-
"/sys/bus/usb/devices/%s:%d.0/%s-port%i/disable",
579-
hub->location, configuration, hub->location, port
580-
);
577+
if (hub->pn_len == 0) {
578+
snprintf(disable_path, PATH_MAX,
579+
"/sys/bus/usb/devices/%s-0:%d.0/usb%s-port%i/disable",
580+
hub->location, configuration, hub->location, port
581+
);
582+
} else {
583+
snprintf(disable_path, PATH_MAX,
584+
"/sys/bus/usb/devices/%s:%d.0/%s-port%i/disable",
585+
hub->location, configuration, hub->location, port
586+
);
587+
}
581588

582589
int disable_fd = open(disable_path, O_WRONLY);
583590
if (disable_fd >= 0) {

0 commit comments

Comments
 (0)