ChangeSet 1.1832.55.32, 2004/09/08 09:44:25-07:00, [EMAIL PROTECTED]

[PATCH] USB: Internal port numbers start at 0

This patch changes a couple of new routines in the suspend/resume code.
Internally they use port numbers starting from 1, unlike every other
routine in the hub driver.  This changes the port numbers to origin-0, for
consistency's sake.  Of course, messages sent to the system log will
continue to start counting from 1.

Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 drivers/usb/core/hub.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)


diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
--- a/drivers/usb/core/hub.c    2004-10-19 08:17:40 -07:00
+++ b/drivers/usb/core/hub.c    2004-10-19 08:17:40 -07:00
@@ -1436,8 +1436,8 @@
        int                     status;
        struct usb_device       *udev;
 
-       udev = hdev->children[port - 1];
-       // dev_dbg(hubdev(hdev), "suspend port %d\n", port);
+       udev = hdev->children[port];
+       // dev_dbg(hubdev(hdev), "suspend port %d\n", port + 1);
 
        /* enable remote wakeup when appropriate; this lets the device
         * wake up the upstream hub (including maybe the root hub).
@@ -1462,11 +1462,11 @@
        }
 
        /* see 7.1.7.6 */
-       status = set_port_feature(hdev, port, USB_PORT_FEAT_SUSPEND);
+       status = set_port_feature(hdev, port + 1, USB_PORT_FEAT_SUSPEND);
        if (status) {
                dev_dbg(hubdev(hdev),
                        "can't suspend port %d, status %d\n",
-                       port, status);
+                       port + 1, status);
                /* paranoia:  "should not happen" */
                (void) usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
                                USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE,
@@ -1585,7 +1585,7 @@
                else
                        status = -EOPNOTSUPP;
        } else
-               status = hub_port_suspend(udev->parent, port + 1);
+               status = hub_port_suspend(udev->parent, port);
 
        if (status == 0)
                udev->dev.power.power_state = state;
@@ -1710,15 +1710,15 @@
        int                     status;
        struct usb_device       *udev;
 
-       udev = hdev->children[port - 1];
-       // dev_dbg(hubdev(hdev), "resume port %d\n", port);
+       udev = hdev->children[port];
+       // dev_dbg(hubdev(hdev), "resume port %d\n", port + 1);
 
        /* see 7.1.7.7; affects power usage, but not budgeting */
-       status = clear_port_feature(hdev, port, USB_PORT_FEAT_SUSPEND);
+       status = clear_port_feature(hdev, port + 1, USB_PORT_FEAT_SUSPEND);
        if (status) {
                dev_dbg(&hdev->actconfig->interface[0]->dev,
                        "can't resume port %d, status %d\n",
-                       port, status);
+                       port + 1, status);
        } else {
                u16             devstatus;
                u16             portchange;
@@ -1736,7 +1736,7 @@
                 * sequence.
                 */
                devstatus = portchange = 0;
-               status = hub_port_status(hdev, port - 1,
+               status = hub_port_status(hdev, port,
                                &devstatus, &portchange);
                if (status < 0
                                || (devstatus & LIVE_FLAGS) != LIVE_FLAGS
@@ -1744,7 +1744,7 @@
                                ) {
                        dev_dbg(&hdev->actconfig->interface[0]->dev,
                                "port %d status %04x.%04x after resume, %d\n",
-                               port, portchange, devstatus, status);
+                               port + 1, portchange, devstatus, status);
                } else {
                        /* TRSMRCY = 10 msec */
                        msleep(10);
@@ -1752,7 +1752,7 @@
                }
        }
        if (status < 0)
-               hub_port_logical_disconnect(hdev, port - 1);
+               hub_port_logical_disconnect(hdev, port);
 
        return status;
 }
@@ -1796,7 +1796,7 @@
                                        ->actconfig->interface[0]);
                }
        } else if (udev->state == USB_STATE_SUSPENDED) {
-               status = hub_port_resume(udev->parent, port + 1);
+               status = hub_port_resume(udev->parent, port);
        } else {
                status = 0;
                udev->dev.power.power_state = PM_SUSPEND_ON;
@@ -1889,7 +1889,7 @@
                        continue;
                down (&udev->serialize);
                if (portstat & USB_PORT_STAT_SUSPEND)
-                       status = hub_port_resume(hdev, port + 1);
+                       status = hub_port_resume(hdev, port);
                else {
                        status = finish_port_resume(udev);
                        if (status < 0) {



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to