Commit 8164fc74 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 7a5baeee
...@@ -1436,8 +1436,8 @@ static int hub_port_suspend(struct usb_device *hdev, int port) ...@@ -1436,8 +1436,8 @@ static int hub_port_suspend(struct usb_device *hdev, int port)
int status; int status;
struct usb_device *udev; struct usb_device *udev;
udev = hdev->children[port - 1]; udev = hdev->children[port];
// dev_dbg(hubdev(hdev), "suspend port %d\n", port); // dev_dbg(hubdev(hdev), "suspend port %d\n", port + 1);
/* enable remote wakeup when appropriate; this lets the device /* enable remote wakeup when appropriate; this lets the device
* wake up the upstream hub (including maybe the root hub). * wake up the upstream hub (including maybe the root hub).
...@@ -1462,11 +1462,11 @@ static int hub_port_suspend(struct usb_device *hdev, int port) ...@@ -1462,11 +1462,11 @@ static int hub_port_suspend(struct usb_device *hdev, int port)
} }
/* see 7.1.7.6 */ /* 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) { if (status) {
dev_dbg(hubdev(hdev), dev_dbg(hubdev(hdev),
"can't suspend port %d, status %d\n", "can't suspend port %d, status %d\n",
port, status); port + 1, status);
/* paranoia: "should not happen" */ /* paranoia: "should not happen" */
(void) usb_control_msg(udev, usb_sndctrlpipe(udev, 0), (void) usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE,
...@@ -1585,7 +1585,7 @@ static int __usb_suspend_device (struct usb_device *udev, int port, u32 state) ...@@ -1585,7 +1585,7 @@ static int __usb_suspend_device (struct usb_device *udev, int port, u32 state)
else else
status = -EOPNOTSUPP; status = -EOPNOTSUPP;
} else } else
status = hub_port_suspend(udev->parent, port + 1); status = hub_port_suspend(udev->parent, port);
if (status == 0) if (status == 0)
udev->dev.power.power_state = state; udev->dev.power.power_state = state;
...@@ -1710,15 +1710,15 @@ hub_port_resume(struct usb_device *hdev, int port) ...@@ -1710,15 +1710,15 @@ hub_port_resume(struct usb_device *hdev, int port)
int status; int status;
struct usb_device *udev; struct usb_device *udev;
udev = hdev->children[port - 1]; udev = hdev->children[port];
// dev_dbg(hubdev(hdev), "resume port %d\n", port); // dev_dbg(hubdev(hdev), "resume port %d\n", port + 1);
/* see 7.1.7.7; affects power usage, but not budgeting */ /* 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) { if (status) {
dev_dbg(&hdev->actconfig->interface[0]->dev, dev_dbg(&hdev->actconfig->interface[0]->dev,
"can't resume port %d, status %d\n", "can't resume port %d, status %d\n",
port, status); port + 1, status);
} else { } else {
u16 devstatus; u16 devstatus;
u16 portchange; u16 portchange;
...@@ -1736,7 +1736,7 @@ hub_port_resume(struct usb_device *hdev, int port) ...@@ -1736,7 +1736,7 @@ hub_port_resume(struct usb_device *hdev, int port)
* sequence. * sequence.
*/ */
devstatus = portchange = 0; devstatus = portchange = 0;
status = hub_port_status(hdev, port - 1, status = hub_port_status(hdev, port,
&devstatus, &portchange); &devstatus, &portchange);
if (status < 0 if (status < 0
|| (devstatus & LIVE_FLAGS) != LIVE_FLAGS || (devstatus & LIVE_FLAGS) != LIVE_FLAGS
...@@ -1744,7 +1744,7 @@ hub_port_resume(struct usb_device *hdev, int port) ...@@ -1744,7 +1744,7 @@ hub_port_resume(struct usb_device *hdev, int port)
) { ) {
dev_dbg(&hdev->actconfig->interface[0]->dev, dev_dbg(&hdev->actconfig->interface[0]->dev,
"port %d status %04x.%04x after resume, %d\n", "port %d status %04x.%04x after resume, %d\n",
port, portchange, devstatus, status); port + 1, portchange, devstatus, status);
} else { } else {
/* TRSMRCY = 10 msec */ /* TRSMRCY = 10 msec */
msleep(10); msleep(10);
...@@ -1752,7 +1752,7 @@ hub_port_resume(struct usb_device *hdev, int port) ...@@ -1752,7 +1752,7 @@ hub_port_resume(struct usb_device *hdev, int port)
} }
} }
if (status < 0) if (status < 0)
hub_port_logical_disconnect(hdev, port - 1); hub_port_logical_disconnect(hdev, port);
return status; return status;
} }
...@@ -1796,7 +1796,7 @@ int usb_resume_device(struct usb_device *udev) ...@@ -1796,7 +1796,7 @@ int usb_resume_device(struct usb_device *udev)
->actconfig->interface[0]); ->actconfig->interface[0]);
} }
} else if (udev->state == USB_STATE_SUSPENDED) { } else if (udev->state == USB_STATE_SUSPENDED) {
status = hub_port_resume(udev->parent, port + 1); status = hub_port_resume(udev->parent, port);
} else { } else {
status = 0; status = 0;
udev->dev.power.power_state = PM_SUSPEND_ON; udev->dev.power.power_state = PM_SUSPEND_ON;
...@@ -1889,7 +1889,7 @@ static int hub_resume(struct usb_interface *intf) ...@@ -1889,7 +1889,7 @@ static int hub_resume(struct usb_interface *intf)
continue; continue;
down (&udev->serialize); down (&udev->serialize);
if (portstat & USB_PORT_STAT_SUSPEND) if (portstat & USB_PORT_STAT_SUSPEND)
status = hub_port_resume(hdev, port + 1); status = hub_port_resume(hdev, port);
else { else {
status = finish_port_resume(udev); status = finish_port_resume(udev);
if (status < 0) { if (status < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment