USB: OHCI: disable RHSC inside interrupt handler
[pandora-kernel.git] / drivers / usb / host / ohci-hcd.c
index 2c614af..a95275a 100644 (file)
@@ -261,7 +261,7 @@ static int ohci_urb_enqueue (
        if (urb->status != -EINPROGRESS) {
                spin_unlock (&urb->lock);
                urb->hcpriv = urb_priv;
-               finish_urb (ohci, urb, NULL);
+               finish_urb (ohci, urb);
                retval = 0;
                goto fail;
        }
@@ -337,7 +337,7 @@ static int ohci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
                 * any more ... just clean up every urb's memory.
                 */
                if (urb->hcpriv)
-                       finish_urb (ohci, urb, NULL);
+                       finish_urb (ohci, urb);
        }
        spin_unlock_irqrestore (&ohci->lock, flags);
        return 0;
@@ -369,7 +369,7 @@ rescan:
        if (!HC_IS_RUNNING (hcd->state)) {
 sanitize:
                ed->state = ED_IDLE;
-               finish_unlinks (ohci, 0, NULL);
+               finish_unlinks (ohci, 0);
        }
 
        switch (ed->state) {
@@ -691,7 +691,7 @@ retry:
 
 /* an interrupt happens */
 
-static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
+static irqreturn_t ohci_irq (struct usb_hcd *hcd)
 {
        struct ohci_hcd         *ohci = hcd_to_ohci (hcd);
        struct ohci_regs __iomem *regs = ohci->regs;
@@ -715,22 +715,6 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
                return IRQ_NOTMINE;
        }
 
-       /* NOTE:  vendors didn't always make the same implementation
-        * choices for RHSC.  Sometimes it triggers on an edge (like
-        * setting and maybe clearing a port status change bit); and
-        * it's level-triggered on other silicon, active until khubd
-        * clears all active port status change bits.  Poll by timer
-        * til it's fully debounced and the difference won't matter.
-        */
-       if (ints & OHCI_INTR_RHSC) {
-               ohci_vdbg (ohci, "rhsc\n");
-               ohci_writel (ohci, OHCI_INTR_RHSC, &regs->intrdisable);
-               hcd->poll_rh = 1;
-               ohci->next_statechange = jiffies + STATECHANGE_DELAY;
-               ohci_writel (ohci, OHCI_INTR_RHSC, &regs->intrstatus);
-               usb_hcd_poll_rh_status(hcd);
-       }
-
        if (ints & OHCI_INTR_UE) {
                disable (ohci);
                ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
@@ -740,18 +724,45 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
                ohci_usb_reset (ohci);
        }
 
-       if (ints & OHCI_INTR_RD) {
-               ohci_vdbg (ohci, "resume detect\n");
-               ohci_writel (ohci, OHCI_INTR_RD, &regs->intrstatus);
-               if (hcd->state != HC_STATE_QUIESCING)
+       if (ints & OHCI_INTR_RHSC) {
+               ohci_vdbg(ohci, "rhsc\n");
+               ohci->next_statechange = jiffies + STATECHANGE_DELAY;
+               ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
+                               &regs->intrstatus);
+
+               /* NOTE: Vendors didn't always make the same implementation
+                * choices for RHSC.  Many followed the spec; RHSC triggers
+                * on an edge, like setting and maybe clearing a port status
+                * change bit.  With others it's level-triggered, active
+                * until khubd clears all the port status change bits.  We'll
+                * always disable it here and rely on polling until khubd
+                * re-enables it.
+                */
+               ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable);
+               usb_hcd_poll_rh_status(hcd);
+       }
+
+       /* For connect and disconnect events, we expect the controller
+        * to turn on RHSC along with RD.  But for remote wakeup events
+        * this might not happen.
+        */
+       else if (ints & OHCI_INTR_RD) {
+               ohci_vdbg(ohci, "resume detect\n");
+               ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
+               hcd->poll_rh = 1;
+               if (ohci->autostop) {
+                       spin_lock (&ohci->lock);
+                       ohci_rh_resume (ohci);
+                       spin_unlock (&ohci->lock);
+               } else
                        usb_hcd_resume_root_hub(hcd);
        }
 
        if (ints & OHCI_INTR_WDH) {
                if (HC_IS_RUNNING(hcd->state))
-                       ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrdisable);  
+                       ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrdisable);
                spin_lock (&ohci->lock);
-               dl_done_list (ohci, ptregs);
+               dl_done_list (ohci);
                spin_unlock (&ohci->lock);
                if (HC_IS_RUNNING(hcd->state))
                        ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrenable); 
@@ -764,7 +775,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
         */
        spin_lock (&ohci->lock);
        if (ohci->ed_rm_list)
-               finish_unlinks (ohci, ohci_frame_no(ohci), ptregs);
+               finish_unlinks (ohci, ohci_frame_no(ohci));
        if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list
                        && HC_IS_RUNNING(hcd->state))
                ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable);   
@@ -795,7 +806,9 @@ static void ohci_stop (struct usb_hcd *hcd)
 
        ohci_usb_reset (ohci);
        ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
-       
+       free_irq(hcd->irq, hcd);
+       hcd->irq = -1;
+
        remove_debug_files (ohci);
        ohci_mem_cleanup (ohci);
        if (ohci->hcca) {
@@ -854,7 +867,7 @@ static int ohci_restart (struct ohci_hcd *ohci)
                urb->status = -ESHUTDOWN;
                spin_unlock (&urb->lock);
        }
-       finish_unlinks (ohci, 0, NULL);
+       finish_unlinks (ohci, 0);
        spin_unlock_irq(&ohci->lock);
 
        /* paranoia, in case that didn't work: */