Plan 9 from Bell Labs’s /sources/contrib/mospak/usb-usbd-hubdesc/usb-usbd-hubdesc.diff

Copyright © 2026 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


--- sys/src/cmd/usb/usbd/usbd.c
+++ sys/src/cmd/usb/usbd/usbd.c
@@ -123,7 +123,7 @@
 	}
 	h->nport = dd->bNbrPorts;
 	nmap = 1 + h->nport/8;
-	if(nr < 7 + 2*nmap){
+	if(nr < 7 + nmap + (h->nport + 7)/8){
 		fprint(2, "%s: %s: descr. too small\n", argv0, h->dev->dir);
 		return -1;
 	}
@@ -141,7 +141,7 @@
 		offset = i/8;
 		mask = 1<<(i%8);
 		pp->removable = (dd->DeviceRemovable[offset] & mask) != 0;
-		pp->pwrctl = (PortPwrCtrlMask[offset] & mask) != 0;
+		pp->pwrctl = (PortPwrCtrlMask[(i-1)/8] & 1<<((i-1)%8)) != 0;
 	}
 	return 0;
 }

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2026 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.