summaryrefslogtreecommitdiff
path: root/sys/src
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2022-06-18 23:37:12 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2022-06-18 23:37:12 +0000
commit990ceeef3bfd9d56e2e6dd39cf5ac185b1a2de08 (patch)
treebebd25b1cdb8640b1d9bcc8e44f8107a4de004f7 /sys/src
parent2b1ecbe87da757ddb12e38239773a05f816d03ae (diff)
nusb/usbd: retry opendevtata() a few times on attach (work around mnt-reform trackball)
this is a known and already fixed issue with version the following version of the mnt-reform trackball firmware: https://source.mnt.re/reform/reform/-/commit/55ca5bf848b57cdf6e7243fc1018411f6c8ab9b5
Diffstat (limited to 'sys/src')
-rw-r--r--sys/src/cmd/nusb/usbd/hub.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/src/cmd/nusb/usbd/hub.c b/sys/src/cmd/nusb/usbd/hub.c
index 1a484625d..e04a4aedc 100644
--- a/sys/src/cmd/nusb/usbd/hub.c
+++ b/sys/src/cmd/nusb/usbd/hub.c
@@ -355,6 +355,7 @@ portattach(Hub *h, int p, u32int sts)
char *sp;
int mp;
int nr;
+ int i;
d = h->dev;
pp = &h->port[p];
@@ -421,9 +422,13 @@ portattach(Hub *h, int p, u32int sts)
nd->isusb3 = h->dev->isusb3;
if(usbdebug > 2)
devctl(nd, "debug 1");
- if(opendevdata(nd, ORDWR) < 0){
+ for(i=0;; i++){
+ if(opendevdata(nd, ORDWR) >= 0)
+ break;
fprint(2, "%s: %s: opendevdata: %r\n", argv0, nd->dir);
- goto Fail;
+ if(i >= 4)
+ goto Fail;
+ sleep(500);
}
if(usbcmd(nd, Rh2d|Rstd|Rdev, Rsetaddress, nd->id, 0, nil, 0) < 0){
dprint(2, "%s: %s: port %d: setaddress: %r\n", argv0, d->dir, p);