Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband
[powerpc.git] / drivers / usb / core / hub.c
index 7479bd3..ba165af 100644 (file)
@@ -291,9 +291,9 @@ void usb_kick_khubd(struct usb_device *hdev)
 
 
 /* completion function, fires on port status changes and various faults */
-static void hub_irq(struct urb *urb, struct pt_regs *regs)
+static void hub_irq(struct urb *urb)
 {
-       struct usb_hub *hub = (struct usb_hub *)urb->context;
+       struct usb_hub *hub = urb->context;
        int status;
        int i;
        unsigned long bits;
@@ -311,7 +311,7 @@ static void hub_irq(struct urb *urb, struct pt_regs *regs)
                        goto resubmit;
                hub->error = urb->status;
                /* FALL THROUGH */
-       
+
        /* let khubd handle things */
        case 0:                 /* we got data:  port status changed */
                bits = 0;
@@ -1053,6 +1053,12 @@ void usb_root_hub_lost_power(struct usb_device *rhdev)
        unsigned long flags;
 
        dev_warn(&rhdev->dev, "root hub lost power or was reset\n");
+
+       /* Make sure no potential wakeup events get lost,
+        * by forcing the root hub to be resumed.
+        */
+       rhdev->dev.power.prev_state.event = PM_EVENT_ON;
+
        spin_lock_irqsave(&device_state_lock, flags);
        hub = hdev_to_hub(rhdev);
        for (port1 = 1; port1 <= rhdev->maxchild; ++port1) {
@@ -1182,6 +1188,7 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
 
 #ifdef CONFIG_USB_OTG
 #include "otg_whitelist.h"
+static int __usb_port_suspend(struct usb_device *, int port1);
 #endif
 
 /**
@@ -1248,8 +1255,7 @@ int usb_new_device(struct usb_device *udev)
                                        USB_DT_OTG, (void **) &desc) == 0) {
                        if (desc->bmAttributes & USB_OTG_HNP) {
                                unsigned                port1 = udev->portnum;
-                               struct usb_device       *root = udev->parent;
-                               
+
                                dev_info(&udev->dev,
                                        "Dual-Role OTG device on %sHNP port\n",
                                        (port1 == bus->otg_port)
@@ -1284,8 +1290,6 @@ int usb_new_device(struct usb_device *udev)
                 * (Includes HNP test device.)
                 */
                if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
-                       static int __usb_port_suspend(struct usb_device *,
-                                               int port1);
                        err = __usb_port_suspend(udev, udev->bus->otg_port);
                        if (err < 0)
                                dev_dbg(&udev->dev, "HNP fail, %d\n", err);
@@ -1774,7 +1778,7 @@ static int remote_wakeup(struct usb_device *udev)
         * to the parent hub! */
 
        usb_lock_device(udev);
-       mutex_lock_nested(&udev->pm_mutex, udev->level);
+       usb_pm_lock(udev);
        if (udev->state == USB_STATE_SUSPENDED) {
                dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-");
                /* TRSMRCY = 10 msec */
@@ -1783,7 +1787,7 @@ static int remote_wakeup(struct usb_device *udev)
                if (status == 0)
                        udev->dev.power.power_state.event = PM_EVENT_ON;
        }
-       mutex_unlock(&udev->pm_mutex);
+       usb_pm_unlock(udev);
 
        if (status == 0)
                usb_autoresume_device(udev, 0);