Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/dev/usb Pull up following revision(s) (requested by m...



details:   https://anonhg.NetBSD.org/src/rev/4499d48c3765
branches:  netbsd-8
changeset: 445584:4499d48c3765
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Nov 04 11:08:10 2018 +0000

description:
Pull up following revision(s) (requested by manu in ticket #1078):

        sys/dev/usb/uhub.c: revision 1.140
        sys/dev/usb/uhub.c: revision 1.141
        sys/dev/usb/usb_subr.c: revision 1.228

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.

 -

Make USB port iteration code consistent, always startint at port #1
This complements change in revision 1.140

diffstat:

 sys/dev/usb/uhub.c     |  24 ++++++++++++------------
 sys/dev/usb/usb_subr.c |  23 ++++++++++++-----------
 2 files changed, 24 insertions(+), 23 deletions(-)

diffs (148 lines):

diff -r 8688d78c7f36 -r 4499d48c3765 sys/dev/usb/uhub.c
--- a/sys/dev/usb/uhub.c        Sat Nov 03 17:20:35 2018 +0000
+++ b/sys/dev/usb/uhub.c        Sun Nov 04 11:08:10 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhub.c,v 1.136.2.2 2018/09/27 14:52:26 martin Exp $    */
+/*     $NetBSD: uhub.c,v 1.136.2.3 2018/11/04 11:08:10 martin 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.136.2.2 2018/09/27 14:52:26 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.136.2.3 2018/11/04 11:08:10 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -412,11 +412,11 @@
                             sizeof(struct usbd_tt), KM_SLEEP);
        }
        /* Set up data structures */
-       for (p = 0; p < nports; p++) {
-               struct usbd_port *up = &hub->uh_ports[p];
+       for (p = 1; p <= nports; p++) {
+               struct usbd_port *up = &hub->uh_ports[p - 1];
                up->up_dev = NULL;
                up->up_parent = dev;
-               up->up_portno = p + 1;
+               up->up_portno = p;
                if (dev->ud_selfpowered)
                        /* Self powered hub, give ports maximum current. */
                        up->up_power = USB_MAX_POWER;
@@ -425,7 +425,7 @@
                up->up_restartcnt = 0;
                up->up_reattach = 0;
                if (UHUB_IS_HIGH_SPEED(sc)) {
-                       up->up_tt = &tts[UHUB_IS_SINGLE_TT(sc) ? 0 : p];
+                       up->up_tt = &tts[UHUB_IS_SINGLE_TT(sc) ? 0 : p - 1];
                        up->up_tt->utt_hub = hub;
                } else {
                        up->up_tt = NULL;
@@ -822,8 +822,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) {
@@ -870,8 +870,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);
@@ -895,8 +895,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++) {
diff -r 8688d78c7f36 -r 4499d48c3765 sys/dev/usb/usb_subr.c
--- a/sys/dev/usb/usb_subr.c    Sat Nov 03 17:20:35 2018 +0000
+++ b/sys/dev/usb/usb_subr.c    Sun Nov 04 11:08:10 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_subr.c,v 1.220.2.5 2018/09/27 14:52:26 martin Exp $        */
+/*     $NetBSD: usb_subr.c,v 1.220.2.6 2018/11/04 11:08:10 martin Exp $        */
 /*     $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $   */
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.220.2.5 2018/09/27 14:52:26 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.220.2.6 2018/11/04 11:08:10 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1230,9 +1230,10 @@
             adev = hub, hub = hub->ud_myhub)
                ;
        if (hub) {
-               for (p = 0; p < hub->ud_hub->uh_hubdesc.bNbrPorts; p++) {
-                       if (hub->ud_hub->uh_ports[p].up_dev == adev) {
-                               dev->ud_myhsport = &hub->ud_hub->uh_ports[p];
+               for (p = 1; p <= hub->ud_hub->uh_hubdesc.bNbrPorts; p++) {
+                       if (hub->ud_hub->uh_ports[p - 1].up_dev == adev) {
+                               dev->ud_myhsport =
+                                   &hub->ud_hub->uh_ports[p - 1];
                                goto found;
                        }
                }
@@ -1558,8 +1559,8 @@
        }
 
        const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
-       for (i = 0; i < __arraycount(di->udi_ports) && i < nports; i++) {
-               p = &dev->ud_hub->uh_ports[i];
+       for (i = 1; i <= __arraycount(di->udi_ports) && i <= nports; i++) {
+               p = &dev->ud_hub->uh_ports[i - 1];
                if (p->up_dev)
                        err = p->up_dev->ud_addr;
                else {
@@ -1581,7 +1582,7 @@
                        else
                                err = USB_PORT_DISABLED;
                }
-               di->udi_ports[i] = err;
+               di->udi_ports[i - 1] = err;
        }
        di->udi_nports = nports;
 }
@@ -1633,9 +1634,9 @@
        }
 
        const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts;
-       for (i = 0; i < __arraycount(di->udi_ports) && i < nports;
+       for (i = 1; i <= __arraycount(di->udi_ports) && i <= nports;
             i++) {
-               p = &dev->ud_hub->uh_ports[i];
+               p = &dev->ud_hub->uh_ports[i - 1];
                if (p->up_dev)
                        err = p->up_dev->ud_addr;
                else {
@@ -1649,7 +1650,7 @@
                        else
                                err = USB_PORT_DISABLED;
                }
-               di->udi_ports[i] = err;
+               di->udi_ports[i - 1] = err;
        }
        di->udi_nports = nports;
 }



Home | Main Index | Thread Index | Old Index