summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-09-05 00:06:20 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-09-05 00:06:20 +0200
commit93063b3db02b3e8b446c56bd28fc3317a3ccf804 (patch)
tree658e46386783ec518a22ffca8d477c32e97dad15
parent0c52215ae32c86751942c3c8c3f784f4a1514731 (diff)
downloadplan9front-93063b3db02b3e8b446c56bd28fc3317a3ccf804.tar.xz
nusbd: properly handle port detach on hub disconnect
-rw-r--r--sys/src/cmd/nusb/usbd/hub.c8
-rw-r--r--sys/src/cmd/nusb/usbd/usbd.c2
2 files changed, 7 insertions, 3 deletions
diff --git a/sys/src/cmd/nusb/usbd/hub.c b/sys/src/cmd/nusb/usbd/hub.c
index 29b1c95af..9dbdc5899 100644
--- a/sys/src/cmd/nusb/usbd/hub.c
+++ b/sys/src/cmd/nusb/usbd/hub.c
@@ -481,6 +481,8 @@ portdetach(Hub *h, int p)
putdevnb(pp->devmaskp, pp->devnb);
pp->devmaskp = nil;
if(pp->dev != nil){
+ detachdev(pp);
+
devctl(pp->dev, "detach");
closedev(pp->dev);
pp->dev = nil;
@@ -562,8 +564,10 @@ portreset(Hub *h, int p)
if(usbcmd(nd, Rh2d|Rstd|Rdev, Rsetconf, 1, 0, nil, 0) < 0)
goto Fail;
}
- if(nd->dfd >= 0)
+ if(nd->dfd >= 0){
close(nd->dfd);
+ nd->dfd = -1;
+ }
return;
Fail:
pp->state = Pdisabled;
@@ -623,8 +627,6 @@ enumhub(Hub *h, int p)
if(attachdev(pp) < 0)
portdetach(h, p);
}else if(portgone(pp, sts)){
- if(pp->dev)
- detachdev(pp);
portdetach(h, p);
}else if(portresetwanted(h, p))
portreset(h, p);
diff --git a/sys/src/cmd/nusb/usbd/usbd.c b/sys/src/cmd/nusb/usbd/usbd.c
index 2e96df07f..74617d8ed 100644
--- a/sys/src/cmd/nusb/usbd/usbd.c
+++ b/sys/src/cmd/nusb/usbd/usbd.c
@@ -338,6 +338,8 @@ attachdev(Port *p)
void
detachdev(Port *p)
{
+ if(p->dev->usb->class == Clhub)
+ return;
pushevent(formatdev(p->dev, 1));
}