From patchwork Mon Apr 16 12:29:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 10342889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B557B60542 for ; Mon, 16 Apr 2018 12:31:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2A3728787 for ; Mon, 16 Apr 2018 12:31:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FF3B286CA; Mon, 16 Apr 2018 12:31:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D610C286D5 for ; Mon, 16 Apr 2018 12:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754642AbeDPMa7 (ORCPT ); Mon, 16 Apr 2018 08:30:59 -0400 Received: from mga05.intel.com ([192.55.52.43]:3050 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753340AbeDPMa6 (ORCPT ); Mon, 16 Apr 2018 08:30:58 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Apr 2018 05:30:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,459,1517904000"; d="scan'208";a="216948449" Received: from pipin.fi.intel.com (HELO localhost) ([10.237.68.37]) by orsmga005.jf.intel.com with ESMTP; 16 Apr 2018 05:30:56 -0700 From: Felipe Balbi To: Mathias Nyman Cc: Linux USB , Felipe Balbi Subject: [PATCH 14/20] usb: host: xhci: extract xhci_cancel_td() Date: Mon, 16 Apr 2018 15:29:24 +0300 Message-Id: <20180416122930.15697-14-felipe.balbi@linux.intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180416122930.15697-1-felipe.balbi@linux.intel.com> References: <20180416122930.15697-1-felipe.balbi@linux.intel.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This little helper is here for readability. It handles the details about how to cancel a TD due to an urb being dequeued. Signed-off-by: Felipe Balbi --- drivers/usb/host/xhci.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index a573c3a444ed..7d5f5cfd14eb 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1429,6 +1429,17 @@ static int xhci_maybe_stop_endpoint(struct xhci_hcd *xhci, return 0; } +static void xhci_cancel_td(struct xhci_virt_ep *ep, struct urb *urb) +{ + struct urb_priv *urb_priv = urb->hcpriv; + int i; + + for (i = urb_priv->num_tds_done; i < urb_priv->num_tds; i++) { + struct xhci_td *td = &urb_priv->td[i]; + list_add_tail(&td->cancelled_td_list, &ep->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 @@ -1467,12 +1478,10 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) struct urb_priv *urb_priv; struct xhci_virt_ep *ep; struct xhci_hcd *xhci; - struct xhci_td *td; unsigned long flags; unsigned int ep_index; u32 temp; int ret; - int i; xhci = hcd_to_xhci(hcd); spin_lock_irqsave(&xhci->lock, flags); @@ -1508,10 +1517,7 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) goto err_giveback; } - for (i = urb_priv->num_tds_done; i < urb_priv->num_tds; i++) { - td = &urb_priv->td[i]; - list_add_tail(&td->cancelled_td_list, &ep->cancelled_td_list); - } + xhci_cancel_td(ep, urb); ret = xhci_maybe_stop_endpoint(xhci, ep, urb, ep_index); done: