From: "Matwey V. Kornilov" <matwey@sai.msu.ru>
To: b-liu@ti.com, gregkh@linuxfoundation.org, stern@rowland.harvard.edu
Cc: matwey.kornilov@gmail.com,
"Matwey V. Kornilov" <matwey@sai.msu.ru>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/6] usb: musb: Introduce musb_qh_free() helper function
Date: Fri, 14 Jun 2019 19:45:51 +0300 [thread overview]
Message-ID: <20190614164554.27679-4-matwey@sai.msu.ru> (raw)
In-Reply-To: <20190614164554.27679-1-matwey@sai.msu.ru>
In-Reply-To: <20190403185310.8437-1-matwey@sai.msu.ru>
Reduce the following similar snippets by using musb_qh_free().
qh->hep->hcpriv = NULL;
list_del(&qh->ring);
kfree(qh);
Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
---
drivers/usb/musb/musb_host.c | 66 +++++++++++++++++++++-----------------------
1 file changed, 32 insertions(+), 34 deletions(-)
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 37aa9f6155d9..5d23c950a21b 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -85,6 +85,21 @@ static bool musb_qh_empty(struct musb_qh *qh)
return list_empty(&qh->hep->urb_list);
}
+static void musb_qh_unlink_hep(struct musb_qh *qh)
+{
+ if (!qh->hep)
+ return;
+
+ qh->hep->hcpriv = NULL;
+}
+
+static void musb_qh_free(struct musb_qh *qh)
+{
+ musb_qh_unlink_hep(qh);
+ list_del(&qh->ring);
+ kfree(qh);
+}
+
/*
* Clear TX fifo. Needed to avoid BABBLE errors.
*/
@@ -348,7 +363,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,
* invalidate qh as soon as list_empty(&hep->urb_list)
*/
if (musb_qh_empty(qh)) {
- struct list_head *head;
+ struct list_head *head = NULL;
struct dma_controller *dma = musb->dma_controller;
if (is_in) {
@@ -367,34 +382,22 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,
/* Clobber old pointers to this qh */
musb_ep_set_qh(ep, is_in, NULL);
- qh->hep->hcpriv = NULL;
- switch (qh->type) {
+ /* USB_ENDPOINT_XFER_CONTROL and USB_ENDPOINT_XFER_BULK: fifo
+ * policy for these lists, except that NAKing should rotate
+ * a qh to the end (for fairness).
+ * USB_ENDPOINT_XFER_ISOC and USB_ENDPOINT_XFER_INT: this is
+ * where periodic bandwidth should be de-allocated if it's
+ * tracked and allocated; and where we'd update the schedule
+ * tree...
+ */
+ if (qh->mux == 1
+ && (qh->type == USB_ENDPOINT_XFER_CONTROL || qh->type == USB_ENDPOINT_XFER_BULK))
+ head = qh->ring.prev;
- case USB_ENDPOINT_XFER_CONTROL:
- case USB_ENDPOINT_XFER_BULK:
- /* fifo policy for these lists, except that NAKing
- * should rotate a qh to the end (for fairness).
- */
- if (qh->mux == 1) {
- head = qh->ring.prev;
- list_del(&qh->ring);
- kfree(qh);
- qh = first_qh(head);
- break;
- }
- /* fall through */
+ musb_qh_free(qh);
- case USB_ENDPOINT_XFER_ISOC:
- case USB_ENDPOINT_XFER_INT:
- /* this is where periodic bandwidth should be
- * de-allocated if it's tracked and allocated;
- * and where we'd update the schedule tree...
- */
- kfree(qh);
- qh = NULL;
- break;
- }
+ qh = head ? first_qh(head) : NULL;
}
if (qh != NULL && qh->is_ready) {
@@ -2435,11 +2438,8 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
/* If nothing else (usually musb_giveback) is using it
* and its URB list has emptied, recycle this qh.
*/
- if (ready && musb_qh_empty(qh)) {
- qh->hep->hcpriv = NULL;
- list_del(&qh->ring);
- kfree(qh);
- }
+ if (ready && musb_qh_empty(qh))
+ musb_qh_free(qh);
} else
ret = musb_cleanup_urb(urb, qh);
done:
@@ -2493,9 +2493,7 @@ musb_h_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
while (!musb_qh_empty(qh))
musb_giveback(musb, next_urb(qh), -ESHUTDOWN);
- hep->hcpriv = NULL;
- list_del(&qh->ring);
- kfree(qh);
+ musb_qh_free(qh);
}
exit:
spin_unlock_irqrestore(&musb->lock, flags);
--
2.16.4
next prev parent reply other threads:[~2019-06-14 17:23 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-03 18:53 [PATCH 0/6] musb: Improve performance for hub-attached webcams Matwey V. Kornilov
2019-04-03 18:53 ` [PATCH 1/6] usb: musb: Use USB_DIR_IN when calling musb_advance_schedule() Matwey V. Kornilov
2019-04-03 18:53 ` [PATCH 2/6] usb: musb: Introduce musb_qh_empty() helper function Matwey V. Kornilov
2019-04-03 18:53 ` [PATCH 3/6] usb: musb: Introduce musb_qh_free() " Matwey V. Kornilov
2019-04-03 18:53 ` [PATCH 4/6] usb: musb: Rename musb_start_urb() to musb_start_next_urb() Matwey V. Kornilov
2019-04-03 18:53 ` [PATCH 5/6] usb: musb: Introduce musb_start_urb() Matwey V. Kornilov
2019-04-03 18:53 ` [PATCH 6/6] usb: musb: Decrease URB starting latency in musb_advance_schedule() Matwey V. Kornilov
2019-04-30 15:31 ` Bin Liu
2019-04-30 17:29 ` Alan Stern
2019-05-04 9:38 ` Matwey V. Kornilov
2019-04-24 15:42 ` [PATCH 0/6] musb: Improve performance for hub-attached webcams Matwey V. Kornilov
2019-04-30 15:20 ` Bin Liu
2019-06-14 16:45 ` [PATCH v2 " Matwey V. Kornilov
2019-06-14 16:45 ` [PATCH v2 1/6] usb: musb: Use USB_DIR_IN when calling musb_advance_schedule() Matwey V. Kornilov
2019-06-14 16:45 ` [PATCH v2 2/6] usb: musb: Introduce musb_qh_empty() helper function Matwey V. Kornilov
2019-06-14 16:45 ` Matwey V. Kornilov [this message]
2019-06-14 16:45 ` [PATCH v2 4/6] usb: musb: Rename musb_start_urb() to musb_start_next_urb() Matwey V. Kornilov
2019-06-14 16:45 ` [PATCH v2 5/6] usb: musb: Introduce musb_start_urb() Matwey V. Kornilov
2019-06-14 16:45 ` [PATCH v2 6/6] usb: musb: Decrease URB starting latency in musb_advance_schedule() Matwey V. Kornilov
2019-07-02 17:29 ` [PATCH v2 0/6] musb: Improve performance for hub-attached webcams Matwey V. Kornilov
2019-07-02 17:33 ` Bin Liu
2019-09-09 16:33 ` Matwey V. Kornilov
2019-10-23 8:12 ` Matwey V. Kornilov
2020-01-01 16:26 ` [PATCH RESEND " Matwey V. Kornilov
2020-01-01 16:26 ` [PATCH RESEND v2 1/6] usb: musb: Use USB_DIR_IN when calling musb_advance_schedule() Matwey V. Kornilov
2020-01-01 16:26 ` [PATCH RESEND v2 2/6] usb: musb: Introduce musb_qh_empty() helper function Matwey V. Kornilov
2020-01-01 16:26 ` [PATCH RESEND v2 3/6] usb: musb: Introduce musb_qh_free() " Matwey V. Kornilov
2020-01-01 16:26 ` [PATCH RESEND v2 4/6] usb: musb: Rename musb_start_urb() to musb_start_next_urb() Matwey V. Kornilov
2020-01-01 16:26 ` [PATCH RESEND v2 5/6] usb: musb: Introduce musb_start_urb() Matwey V. Kornilov
2020-01-01 16:26 ` [PATCH RESEND v2 6/6] usb: musb: Decrease URB starting latency in musb_advance_schedule() Matwey V. Kornilov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190614164554.27679-4-matwey@sai.msu.ru \
--to=matwey@sai.msu.ru \
--cc=b-liu@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=matwey.kornilov@gmail.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).