OSDN Git Service

Merge "usb: XHCI: Implement xhci_handshake_check_state() API"
authorLinux Build Service Account <lnxbuild@localhost>
Fri, 12 Apr 2019 05:13:29 +0000 (22:13 -0700)
committerGerrit - the friendly Code Review server <code-review@localhost>
Fri, 12 Apr 2019 05:13:28 +0000 (22:13 -0700)
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h

index 3e11317..0ccd5ce 100644 (file)
@@ -77,6 +77,27 @@ int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec)
        return -ETIMEDOUT;
 }
 
+int xhci_handshake_check_state(struct xhci_hcd *xhci,
+               void __iomem *ptr, u32 mask, u32 done, int usec)
+{
+       u32     result;
+
+       do {
+               result = readl_relaxed(ptr);
+               if (result == ~(u32)0) /* card removed */
+                       return -ENODEV;
+               /* host removed. Bail out */
+               if (xhci->xhc_state & XHCI_STATE_REMOVING)
+                       return -ENODEV;
+               result &= mask;
+               if (result == done)
+                       return 0;
+               udelay(1);
+               usec--;
+       } while (usec > 0);
+       return -ETIMEDOUT;
+}
+
 /*
  * Disable interrupts and begin the xHCI halting process.
  */
index 5800dda..c0928f4 100644 (file)
@@ -1836,6 +1836,8 @@ int xhci_sec_event_ring_cleanup(struct usb_hcd *hcd, unsigned intr_num);
 /* xHCI host controller glue */
 typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
 int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec);
+int xhci_handshake_check_state(struct xhci_hcd *xhci,
+               void __iomem *ptr, u32 mask, u32 done, int usec);
 void xhci_quiesce(struct xhci_hcd *xhci);
 int xhci_halt(struct xhci_hcd *xhci);
 int xhci_reset(struct xhci_hcd *xhci);