All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@163.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: Geliang Tang <geliangtang@163.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/9] usb: host: max3421-hcd: use list_for_each_entry*
Date: Sat, 19 Dec 2015 00:34:27 +0800	[thread overview]
Message-ID: <45e8397e370ed99ceb8aa1719c2b56a7ce741eb3.1450455485.git.geliangtang@163.com> (raw)
In-Reply-To: <1ec91b8ad8d81a446e08f3c4f15f2d3df620b186.1450455485.git.geliangtang@163.com>
In-Reply-To: <1ec91b8ad8d81a446e08f3c4f15f2d3df620b186.1450455485.git.geliangtang@163.com>

Use list_for_each_entry*() instead of list_for_each*() to simplify
the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 drivers/usb/host/max3421-hcd.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
index bd98706..7257962 100644
--- a/drivers/usb/host/max3421-hcd.c
+++ b/drivers/usb/host/max3421-hcd.c
@@ -665,7 +665,6 @@ max3421_select_and_start_urb(struct usb_hcd *hcd)
 	struct max3421_ep *max3421_ep;
 	int epnum, force_toggles = 0;
 	struct usb_host_endpoint *ep;
-	struct list_head *pos;
 	unsigned long flags;
 
 	spin_lock_irqsave(&max3421_hcd->lock, flags);
@@ -673,10 +672,9 @@ max3421_select_and_start_urb(struct usb_hcd *hcd)
 	for (;
 	     max3421_hcd->sched_pass < SCHED_PASS_DONE;
 	     ++max3421_hcd->sched_pass)
-		list_for_each(pos, &max3421_hcd->ep_list) {
+		list_for_each_entry(max3421_ep, &max3421_hcd->ep_list,
+				    ep_list) {
 			urb = NULL;
-			max3421_ep = container_of(pos, struct max3421_ep,
-						  ep_list);
 			ep = max3421_ep->ep;
 
 			switch (usb_endpoint_type(&ep->desc)) {
@@ -748,7 +746,8 @@ max3421_select_and_start_urb(struct usb_hcd *hcd)
 			}
 
 			/* move current ep to tail: */
-			list_move_tail(pos, &max3421_hcd->ep_list);
+			list_move_tail(&max3421_ep->ep_list,
+				       &max3421_hcd->ep_list);
 			curr_urb = urb;
 			goto done;
 		}
@@ -797,19 +796,16 @@ max3421_check_unlink(struct usb_hcd *hcd)
 {
 	struct spi_device *spi = to_spi_device(hcd->self.controller);
 	struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd);
-	struct list_head *pos, *upos, *next_upos;
 	struct max3421_ep *max3421_ep;
 	struct usb_host_endpoint *ep;
-	struct urb *urb;
+	struct urb *urb, *next;
 	unsigned long flags;
 	int retval = 0;
 
 	spin_lock_irqsave(&max3421_hcd->lock, flags);
-	list_for_each(pos, &max3421_hcd->ep_list) {
-		max3421_ep = container_of(pos, struct max3421_ep, ep_list);
+	list_for_each_entry(max3421_ep, &max3421_hcd->ep_list, ep_list) {
 		ep = max3421_ep->ep;
-		list_for_each_safe(upos, next_upos, &ep->urb_list) {
-			urb = container_of(upos, struct urb, urb_list);
+		list_for_each_entry_safe(urb, next, &ep->urb_list, urb_list) {
 			if (urb->unlinked) {
 				retval = 1;
 				dev_dbg(&spi->dev, "%s: URB %p unlinked=%d",
@@ -1184,22 +1180,19 @@ dump_eps(struct usb_hcd *hcd)
 	struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd);
 	struct max3421_ep *max3421_ep;
 	struct usb_host_endpoint *ep;
-	struct list_head *pos, *upos;
 	char ubuf[512], *dp, *end;
 	unsigned long flags;
 	struct urb *urb;
 	int epnum, ret;
 
 	spin_lock_irqsave(&max3421_hcd->lock, flags);
-	list_for_each(pos, &max3421_hcd->ep_list) {
-		max3421_ep = container_of(pos, struct max3421_ep, ep_list);
+	list_for_each_entry(max3421_ep, &max3421_hcd->ep_list, ep_list) {
 		ep = max3421_ep->ep;
 
 		dp = ubuf;
 		end = dp + sizeof(ubuf);
 		*dp = '\0';
-		list_for_each(upos, &ep->urb_list) {
-			urb = container_of(upos, struct urb, urb_list);
+		list_for_each_entry(urb, &ep->urb_list, urb_list) {
 			ret = snprintf(dp, end - dp, " %p(%d.%s %d/%d)", urb,
 				       usb_pipetype(urb->pipe),
 				       usb_urb_dir_in(urb) ? "IN" : "OUT",
-- 
2.5.0



  reply	other threads:[~2015-12-18 16:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18 16:34 [PATCH 1/9] usb: host: fotg210: use list_for_each_entry_safe Geliang Tang
2015-12-18 16:34 ` Geliang Tang [this message]
2015-12-18 16:34 ` [PATCH 3/9] usb: host: oxu210hp-hcd: " Geliang Tang
2015-12-18 16:34 ` [PATCH 4/9] usb: host: u132-hcd: use list_for_each_entry Geliang Tang
2015-12-18 16:34 ` [PATCH 5/9] usb: xhci: " Geliang Tang
2015-12-18 16:34 ` [PATCH 6/9] usb: chipidea: debug: " Geliang Tang
2015-12-25  7:41   ` Peter Chen
2015-12-18 16:34 ` [PATCH 7/9] usb: dwc2: host: use list_for_each_entry_safe Geliang Tang
2015-12-18 16:34 ` [PATCH 8/9] usb: gadget: rndis: " Geliang Tang
2015-12-22 18:07   ` Felipe Balbi
2015-12-23 13:51     ` [PATCH 8/9 v2] " Geliang Tang
2015-12-18 16:34 ` [PATCH 9/9] usb: gadget: bcm63xx_udc: " Geliang Tang
     [not found] <201512190149.tp8A4V4C%fengguang.wu@intel.com>
2015-12-18 17:53 ` [PATCH 2/9] usb: host: max3421-hcd: use list_for_each_entry* Julia Lawall

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=45e8397e370ed99ceb8aa1719c2b56a7ce741eb3.1450455485.git.geliangtang@163.com \
    --to=geliangtang@163.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.