]> git.lizzy.rs Git - plan9front.git/commitdiff
nusbd: properly handle port detach on hub disconnect
authorcinap_lenrek <cinap_lenrek@gmx.de>
Tue, 4 Sep 2012 22:06:20 +0000 (00:06 +0200)
committercinap_lenrek <cinap_lenrek@gmx.de>
Tue, 4 Sep 2012 22:06:20 +0000 (00:06 +0200)
sys/src/cmd/nusb/usbd/hub.c
sys/src/cmd/nusb/usbd/usbd.c

index 29b1c95afb09959ec5cdf95b26a956bfaf90fedd..9dbdc589968dcba484407e3fe8604160905b21af 100644 (file)
@@ -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);
index 2e96df07f92a248bef1a11d1c7d0ad64bbe6eb74..74617d8ed4ad34e41594911e600c2b783b032b20 100644 (file)
@@ -338,6 +338,8 @@ attachdev(Port *p)
 void
 detachdev(Port *p)
 {
+       if(p->dev->usb->class == Clhub)
+               return;
        pushevent(formatdev(p->dev, 1));
 }