Module Name:    src
Committed By:   manu
Date:           Fri Oct 19 00:33:27 UTC 2018

Modified Files:
        src/sys/dev/usb: uhub.c

Log Message:
Make USB port numbers display consistent

Make sure USB ports numbers are displayed with the first one as number one
and not number zero when rescanning bus. The change makes the display
consistent with the display at boot time USB discovery.

While we are there, make port iteration consistent everywhere in the code,
always starting at one instead of zero.


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/sys/dev/usb/uhub.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.139 src/sys/dev/usb/uhub.c:1.140
--- src/sys/dev/usb/uhub.c:1.139	Tue Sep 18 01:36:44 2018
+++ src/sys/dev/usb/uhub.c	Fri Oct 19 00:33:27 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.139 2018/09/18 01:36:44 mrg Exp $	*/
+/*	$NetBSD: uhub.c,v 1.140 2018/10/19 00:33:27 manu Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 /*	$OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.139 2018/09/18 01:36:44 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.140 2018/10/19 00:33:27 manu Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -823,8 +823,8 @@ uhub_detach(device_t self, int flags)
 	KERNEL_LOCK(1, curlwp);
 
 	nports = hub->uh_hubdesc.bNbrPorts;
-	for (port = 0; port < nports; port++) {
-		rup = &hub->uh_ports[port];
+	for (port = 1; port <= nports; port++) {
+		rup = &hub->uh_ports[port - 1];
 		if (rup->up_dev == NULL)
 			continue;
 		if ((rc = usb_disconnect_port(rup, self, flags)) != 0) {
@@ -871,8 +871,8 @@ uhub_rescan(device_t self, const char *i
 	struct usbd_device *dev;
 	int port;
 
-	for (port = 0; port < hub->uh_hubdesc.bNbrPorts; port++) {
-		dev = hub->uh_ports[port].up_dev;
+	for (port = 1; port <= hub->uh_hubdesc.bNbrPorts; port++) {
+		dev = hub->uh_ports[port - 1].up_dev;
 		if (dev == NULL)
 			continue;
 		usbd_reattach_device(sc->sc_dev, dev, port, locators);
@@ -896,8 +896,8 @@ uhub_childdet(device_t self, device_t ch
 		panic("hub not fully initialised, but child deleted?");
 
 	nports = devhub->ud_hub->uh_hubdesc.bNbrPorts;
-	for (port = 0; port < nports; port++) {
-		dev = devhub->ud_hub->uh_ports[port].up_dev;
+	for (port = 1; port <= nports; port++) {
+		dev = devhub->ud_hub->uh_ports[port - 1].up_dev;
 		if (!dev || dev->ud_subdevlen == 0)
 			continue;
 		for (i = 0; i < dev->ud_subdevlen; i++) {

Reply via email to