Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Make USB port numbers display consistent



details:   https://anonhg.NetBSD.org/src/rev/7aea2583882f
branches:  trunk
changeset: 445236:7aea2583882f
user:      manu <manu%NetBSD.org@localhost>
date:      Fri Oct 19 00:33:27 2018 +0000

description:
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.

diffstat:

 sys/dev/usb/uhub.c |  16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diffs (51 lines):

diff -r f8ee99352501 -r 7aea2583882f sys/dev/usb/uhub.c
--- a/sys/dev/usb/uhub.c        Fri Oct 19 00:32:47 2018 +0000
+++ b/sys/dev/usb/uhub.c        Fri Oct 19 00:33:27 2018 +0000
@@ -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 @@
        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 @@
        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 @@
                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++) {



Home | Main Index | Thread Index | Old Index