shithub: plan9front

Download patch

ref: 5bce05b759c695fdd5bc71fe04c00407406e644b
parent: 95ea8f77397d2e768cef319bea78fc15ad8496d1
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Jan 5 00:58:33 EST 2023

devusb: provide usb hub device number instead of address in /dev/usb/ctl

The hub address is only usefull for the host controller
driver, while userspace really cares about the device number.

--- a/sys/src/9/port/devusb.c
+++ b/sys/src/9/port/devusb.c
@@ -298,7 +298,7 @@
 	s = seprint(s, se, " samplesz %ld", ep->samplesz);
 	s = seprint(s, se, " hz %ld", ep->hz);
 	s = seprint(s, se, " uframes %d", ep->uframes);
-	s = seprint(s, se, " hub %d", ep->dev->hub);
+	s = seprint(s, se, " hub %d", ep->dev->hubnb);
 	s = seprint(s, se, " port %d", ep->dev->port);
 	s = seprint(s, se, " rootport %d", ep->dev->rootport);
 	s = seprint(s, se, " addr %d", ep->dev->addr);
@@ -1277,6 +1277,7 @@
 			nep->maxpkt = 512;
 		else if(l != Lowspeed)
 			nep->maxpkt = 64;	/* assume full speed */
+		nep->dev->hubnb = d->nb;
 		nep->dev->hub = d->addr;
 		nep->dev->port = atoi(cb->f[2]);
 		nep->dev->depth = d->depth+1;
--- a/sys/src/9/port/portmkfile
+++ b/sys/src/9/port/portmkfile
@@ -109,7 +109,7 @@
 devaoe.$O sdaoe.$O:	/sys/include/fis.h
 sysproc.$O:	/sys/include/a.out.h
 syscallfmt.$O:	/sys/src/libc/9syscall/sys.h
-devusb.$O usbxhci.$O:	../port/usb.h
+devusb.$O usbxhci.$O usbxhcipci.$O:	../port/usb.h
 usbxhci.$O usbxhcipci.$O:	../port/usbxhci.h
 devether.$O ethersink.$O:	../port/etherif.h ../port/netif.h
 wifi.$O:	../port/etherif.h ../port/netif.h ../port/wifi.h /sys/include/libsec.h
--- a/sys/src/9/port/usb.h
+++ b/sys/src/9/port/usb.h
@@ -187,6 +187,7 @@
 	int	ishub;		/* hubs can allocate devices */
 	int	isroot;		/* is a root hub */
 	int	speed;		/* Full/Low/High/Super/No -speed */
+	int	hubnb;		/* USB device number for the parent hub */
 	int	hub;		/* device address for the parent hub */
 	int	port;		/* port number in the parent hub */
 	int	addr;		/* device address */