Skip to content

Commit

Permalink
libusb: lookup devfs in addition to /dev when connecting
Browse files Browse the repository at this point in the history
This allows usb to be loaded from syspage (e.g. so that umass can be
used for rootfs mounting)

JIRA: RTOS-937
  • Loading branch information
adamgreloch committed Dec 2, 2024
1 parent b39b4cc commit 1f3319f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions libusb/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1f3319f

Please sign in to comment.