diff mbox

[10/20] usb: host: xhci: check DYING state earlier

Message ID 20180416122930.15697-10-felipe.balbi@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Felipe Balbi April 16, 2018, 12:29 p.m. UTC
in case where xHCI dies, we can bail out a little earlier. Not really
a functional change, just making the code follow a more
straight-forward order.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
 drivers/usb/host/xhci.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 3b19444aa1f3..6be3eb721157 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1444,6 +1444,13 @@  static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 	if (ret)
 		goto done;
 
+	/* If xHC is dead take it down and return ALL URBs in xhci_hc_died() */
+	temp = readl(&xhci->op_regs->status);
+	if (temp == ~(u32)0 || xhci->xhc_state & XHCI_STATE_DYING) {
+		xhci_hc_died(xhci);
+		goto done;
+	}
+
 	/* give back URB now if we can't queue it for cancel */
 	vdev = xhci->devs[urb->dev->slot_id];
 	urb_priv = urb->hcpriv;
@@ -1456,13 +1463,6 @@  static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 	if (!ep || !ep_ring)
 		goto err_giveback;
 
-	/* If xHC is dead take it down and return ALL URBs in xhci_hc_died() */
-	temp = readl(&xhci->op_regs->status);
-	if (temp == ~(u32)0 || xhci->xhc_state & XHCI_STATE_DYING) {
-		xhci_hc_died(xhci);
-		goto done;
-	}
-
 	if (xhci->xhc_state & XHCI_STATE_HALTED) {
 		xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
 				"HC halted, freeing TD manually.");