summaryrefslogtreecommitdiff
path: root/sys/src/cmd/nusb
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-04-05 03:05:06 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2020-04-05 03:05:06 +0200
commitecba7822e316d6cb8370eec97862215402811e82 (patch)
tree494dc254651a6d72810f31e2ee0c6c21c4854faa /sys/src/cmd/nusb
parent315f20b9f46671ca1fd323b22de0722c7c561f97 (diff)
nusb/usbd: fix portreset error handling
error handling in portreset() was wrong. we called closedev() on the device without changing the reference. just call portdetach() when the reset fails.
Diffstat (limited to 'sys/src/cmd/nusb')
-rw-r--r--sys/src/cmd/nusb/usbd/hub.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/sys/src/cmd/nusb/usbd/hub.c b/sys/src/cmd/nusb/usbd/hub.c
index b6d1a915b..1a484625d 100644
--- a/sys/src/cmd/nusb/usbd/hub.c
+++ b/sys/src/cmd/nusb/usbd/hub.c
@@ -543,7 +543,6 @@ portreset(Hub *h, int p)
d = h->dev;
pp = &h->port[p];
- nd = pp->dev;
dprint(2, "%s: %s: port %d: resetting\n", argv0, d->dir, p);
if(hubfeature(h, p, Fportreset, 1) < 0){
dprint(2, "%s: %s: port %d: reset: %r\n", argv0, d->dir, p);
@@ -557,7 +556,8 @@ portreset(Hub *h, int p)
dprint(2, "%s: %s: port %d: not enabled?\n", argv0, d->dir, p);
goto Fail;
}
- nd = pp->dev;
+ if((nd = pp->dev) == nil)
+ return;
opendevdata(nd, ORDWR);
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);
@@ -579,15 +579,10 @@ portreset(Hub *h, int p)
}
return;
Fail:
- pp->state = Pdisabled;
pp->sts = 0;
- if(pp->hub != nil)
- pp->hub = nil; /* hub closed by enumhub */
- if(!h->dev->isusb3)
+ portdetach(h, p);
+ if(!d->isusb3)
hubfeature(h, p, Fportenable, 0);
- if(nd != nil)
- devctl(nd, "detach");
- closedev(nd);
}
static int