diff mbox

[11/20] usb: host: xhci: extract xhci_manually_free_td() helper

Message ID 20180416122930.15697-11-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
Cleanup only, no functional changes.

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

Patch

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6be3eb721157..5d2c24f58b34 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1388,6 +1388,25 @@  static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 	return ret;
 }
 
+static void xhci_manually_free_td(struct xhci_hcd *xhci, struct urb *urb)
+{
+	struct urb_priv	*urb_priv = urb->hcpriv;
+	int i;
+
+	xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
+			"HC halted, freeing TD manually.");
+
+	for (i = urb_priv->num_tds_done; i < urb_priv->num_tds; i++) {
+		struct xhci_td *td = &urb_priv->td[i];
+
+		if (!list_empty(&td->td_list))
+			list_del_init(&td->td_list);
+
+		if (!list_empty(&td->cancelled_td_list))
+			list_del_init(&td->cancelled_td_list);
+	}
+}
+
 /*
  * Remove the URB's TD from the endpoint ring.  This may cause the HC to stop
  * USB transfers, potentially stopping in the middle of a TRB buffer.  The HC
@@ -1464,17 +1483,7 @@  static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 		goto err_giveback;
 
 	if (xhci->xhc_state & XHCI_STATE_HALTED) {
-		xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
-				"HC halted, freeing TD manually.");
-		for (i = urb_priv->num_tds_done;
-		     i < urb_priv->num_tds;
-		     i++) {
-			td = &urb_priv->td[i];
-			if (!list_empty(&td->td_list))
-				list_del_init(&td->td_list);
-			if (!list_empty(&td->cancelled_td_list))
-				list_del_init(&td->cancelled_td_list);
-		}
+		xhci_manually_free_td(xhci, urb);
 		goto err_giveback;
 	}