Skip to content

Commit 7e994d8

Browse files
authored
netbsd: check not only addr 0 but also addr 1 to find root hubs (#780)
On NetBSD xhci(4) uses 'addr 0' for the root hub but all drivers for other host controllers use 'addr 1' for the root hub. https://gnats.netbsd.org/60073
1 parent 55aab02 commit 7e994d8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

netbsd/hid.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor
724724
for (size_t i = 0; i < len; i++) {
725725
char devpath[USB_MAX_DEVNAMELEN];
726726
int bus;
727+
struct hid_device_info *prev_end;
727728

728729
strlcpy(devpath, "/dev/", sizeof(devpath));
729730
strlcat(devpath, arr[i], sizeof(devpath));
@@ -732,7 +733,17 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor
732733
if (bus == -1)
733734
continue;
734735

736+
/*
737+
* ehci/ohci/uhci/dwctwo etc. use 'addr 1' for root hubs
738+
* but xhci uses 'addr 0' on NetBSD.
739+
* Check addr 0 (that would be unused on other than xhci)
740+
* and then check addr 1 if there is no device at addr 0.
741+
*/
742+
prev_end = hed.end;
735743
enumerate_usb_devices(bus, 0, hid_enumerate_callback, &hed);
744+
if (hed.end == prev_end)
745+
enumerate_usb_devices(bus, 1,
746+
hid_enumerate_callback, &hed);
736747

737748
close(bus);
738749
}

0 commit comments

Comments
 (0)