Commit 1d4b0111 authored by Sarah Sharp's avatar Sarah Sharp Committed by Greg Kroah-Hartman

USB: Prepare for refactoring by adding extra udev checks.

[This is upstream commit 2d4fa940.
It needs to be backported to kernels as old as 3.2, because it fixes the
buggy commit 65bdac5e "USB: Handle warm
reset failure on empty port."]

The next patch will refactor the hub port code to rip out the recursive
call to hub_port_reset on a failed hot reset.  In preparation for that,
make sure all code paths can deal with being called with a NULL udev.
The usb_device will not be valid if warm reset was issued because a port
transitioned to the Inactive or Compliance Mode on a device connect.

This patch should have no effect on current behavior.
Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4b996365
...@@ -2584,6 +2584,9 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1, ...@@ -2584,6 +2584,9 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
return -ENOTCONN; return -ENOTCONN;
if ((portstatus & USB_PORT_STAT_ENABLE)) { if ((portstatus & USB_PORT_STAT_ENABLE)) {
if (!udev)
return 0;
if (hub_is_wusb(hub)) if (hub_is_wusb(hub))
udev->speed = USB_SPEED_WIRELESS; udev->speed = USB_SPEED_WIRELESS;
else if (hub_is_superspeed(hub->hdev)) else if (hub_is_superspeed(hub->hdev))
...@@ -2627,14 +2630,16 @@ static void hub_port_finish_reset(struct usb_hub *hub, int port1, ...@@ -2627,14 +2630,16 @@ static void hub_port_finish_reset(struct usb_hub *hub, int port1,
struct usb_hcd *hcd; struct usb_hcd *hcd;
/* TRSTRCY = 10 ms; plus some extra */ /* TRSTRCY = 10 ms; plus some extra */
msleep(10 + 40); msleep(10 + 40);
if (udev) {
update_devnum(udev, 0); update_devnum(udev, 0);
hcd = bus_to_hcd(udev->bus); hcd = bus_to_hcd(udev->bus);
/* The xHC may think the device is already reset, /* The xHC may think the device is already
* so ignore the status. * reset, so ignore the status.
*/ */
if (hcd->driver->reset_device) if (hcd->driver->reset_device)
hcd->driver->reset_device(hcd, udev); hcd->driver->reset_device(hcd, udev);
} }
}
/* FALL THROUGH */ /* FALL THROUGH */
case -ENOTCONN: case -ENOTCONN:
case -ENODEV: case -ENODEV:
...@@ -2647,7 +2652,7 @@ static void hub_port_finish_reset(struct usb_hub *hub, int port1, ...@@ -2647,7 +2652,7 @@ static void hub_port_finish_reset(struct usb_hub *hub, int port1,
clear_port_feature(hub->hdev, port1, clear_port_feature(hub->hdev, port1,
USB_PORT_FEAT_C_PORT_LINK_STATE); USB_PORT_FEAT_C_PORT_LINK_STATE);
} }
if (!warm) if (!warm && udev)
usb_set_device_state(udev, *status usb_set_device_state(udev, *status
? USB_STATE_NOTATTACHED ? USB_STATE_NOTATTACHED
: USB_STATE_DEFAULT); : USB_STATE_DEFAULT);
......
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