From 1f3319f02540ecbaf238a111c59ba19e6c1873c3 Mon Sep 17 00:00:00 2001 From: Adam Greloch Date: Wed, 6 Nov 2024 15:31:57 +0100 Subject: [PATCH] libusb: lookup `devfs` in addition to `/dev` when connecting This allows usb to be loaded from syspage (e.g. so that umass can be used for rootfs mounting) JIRA: RTOS-937 --- libusb/driver.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/libusb/driver.c b/libusb/driver.c index fe92268..02fdaaf 100644 --- a/libusb/driver.c +++ b/libusb/driver.c @@ -23,14 +23,33 @@ static struct { } usbdrv_common; +static void usb_hostLookup(oid_t *oid) +{ + int ret; + + for (;;) { + ret = lookup("devfs/usb", NULL, oid); + if (ret >= 0) { + break; + } + + ret = lookup("/dev/usb", NULL, oid); + if (ret >= 0) { + break; + } + + usleep(1000000); + } +} + + int usb_connect(const usb_device_id_t *filters, int nfilters, unsigned drvport) { msg_t msg = { 0 }; usb_msg_t *umsg = (usb_msg_t *)&msg.i.raw; oid_t oid; - while (lookup("/dev/usb", NULL, &oid) < 0) - usleep(1000000); + usb_hostLookup(&oid); msg.type = mtDevCtl; msg.i.size = sizeof(*filters) * nfilters;