public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] usb: host: fotg210: use list_for_each_entry_safe
@ 2015-12-18 16:34 Geliang Tang
  2015-12-18 16:34 ` [PATCH 2/9] usb: host: max3421-hcd: use list_for_each_entry* Geliang Tang
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Geliang Tang @ 2015-12-18 16:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Peter Senna Tschudin, Sergei Shtylyov
  Cc: Geliang Tang, linux-usb, linux-kernel

Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 drivers/usb/host/fotg210-hcd.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index 2341af4..360a5e9 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -2267,7 +2267,7 @@ static unsigned qh_completions(struct fotg210_hcd *fotg210,
 		struct fotg210_qh *qh)
 {
 	struct fotg210_qtd *last, *end = qh->dummy;
-	struct list_head *entry, *tmp;
+	struct fotg210_qtd *qtd, *tmp;
 	int last_status;
 	int stopped;
 	unsigned count = 0;
@@ -2301,12 +2301,10 @@ rescan:
 	 * then let the queue advance.
 	 * if queue is stopped, handles unlinks.
 	 */
-	list_for_each_safe(entry, tmp, &qh->qtd_list) {
-		struct fotg210_qtd *qtd;
+	list_for_each_entry_safe(qtd, tmp, &qh->qtd_list, qtd_list) {
 		struct urb *urb;
 		u32 token = 0;
 
-		qtd = list_entry(entry, struct fotg210_qtd, qtd_list);
 		urb = qtd->urb;
 
 		/* clean up any state from previous QTD ...*/
@@ -2544,14 +2542,11 @@ retry_xacterr:
  * used for cleanup after errors, before HC sees an URB's TDs.
  */
 static void qtd_list_free(struct fotg210_hcd *fotg210, struct urb *urb,
-		struct list_head *qtd_list)
+		struct list_head *head)
 {
-	struct list_head *entry, *temp;
-
-	list_for_each_safe(entry, temp, qtd_list) {
-		struct fotg210_qtd *qtd;
+	struct fotg210_qtd *qtd, *temp;
 
-		qtd = list_entry(entry, struct fotg210_qtd, qtd_list);
+	list_for_each_entry_safe(qtd, temp, head, qtd_list) {
 		list_del(&qtd->qtd_list);
 		fotg210_qtd_free(fotg210, qtd);
 	}
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/9] usb: host: max3421-hcd: use list_for_each_entry*
  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
  2015-12-18 16:34 ` [PATCH 3/9] usb: host: oxu210hp-hcd: use list_for_each_entry_safe Geliang Tang
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Geliang Tang @ 2015-12-18 16:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Sergei Shtylyov; +Cc: Geliang Tang, linux-usb, linux-kernel

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



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/9] usb: host: oxu210hp-hcd: use list_for_each_entry_safe
  2015-12-18 16:34 [PATCH 1/9] usb: host: fotg210: use list_for_each_entry_safe Geliang Tang
  2015-12-18 16:34 ` [PATCH 2/9] usb: host: max3421-hcd: use list_for_each_entry* Geliang Tang
@ 2015-12-18 16:34 ` Geliang Tang
  2015-12-18 16:34 ` [PATCH 4/9] usb: host: u132-hcd: use list_for_each_entry Geliang Tang
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Geliang Tang @ 2015-12-18 16:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Sergei Shtylyov; +Cc: Geliang Tang, linux-usb, linux-kernel

Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 drivers/usb/host/oxu210hp-hcd.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index bc74aca..4e4d601 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -981,7 +981,7 @@ static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
 static unsigned qh_completions(struct oxu_hcd *oxu, struct ehci_qh *qh)
 {
 	struct ehci_qtd *last = NULL, *end = qh->dummy;
-	struct list_head *entry, *tmp;
+	struct ehci_qtd	*qtd, *tmp;
 	int stopped;
 	unsigned count = 0;
 	int do_status = 0;
@@ -1006,12 +1006,10 @@ static unsigned qh_completions(struct oxu_hcd *oxu, struct ehci_qh *qh)
 	 * then let the queue advance.
 	 * if queue is stopped, handles unlinks.
 	 */
-	list_for_each_safe(entry, tmp, &qh->qtd_list) {
-		struct ehci_qtd	*qtd;
+	list_for_each_entry_safe(qtd, tmp, &qh->qtd_list, qtd_list) {
 		struct urb *urb;
 		u32 token = 0;
 
-		qtd = list_entry(entry, struct ehci_qtd, qtd_list);
 		urb = qtd->urb;
 
 		/* Clean up any state from previous QTD ...*/
@@ -1174,14 +1172,11 @@ halt:
  * used for cleanup after errors, before HC sees an URB's TDs.
  */
 static void qtd_list_free(struct oxu_hcd *oxu,
-				struct urb *urb, struct list_head *qtd_list)
+				struct urb *urb, struct list_head *head)
 {
-	struct list_head *entry, *temp;
-
-	list_for_each_safe(entry, temp, qtd_list) {
-		struct ehci_qtd	*qtd;
+	struct ehci_qtd	*qtd, *temp;
 
-		qtd = list_entry(entry, struct ehci_qtd, qtd_list);
+	list_for_each_entry_safe(qtd, temp, head, qtd_list) {
 		list_del(&qtd->qtd_list);
 		oxu_qtd_free(oxu, qtd);
 	}
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/9] usb: host: u132-hcd: use list_for_each_entry
  2015-12-18 16:34 [PATCH 1/9] usb: host: fotg210: use list_for_each_entry_safe Geliang Tang
  2015-12-18 16:34 ` [PATCH 2/9] usb: host: max3421-hcd: use list_for_each_entry* Geliang Tang
  2015-12-18 16:34 ` [PATCH 3/9] usb: host: oxu210hp-hcd: use list_for_each_entry_safe Geliang Tang
@ 2015-12-18 16:34 ` Geliang Tang
  2015-12-18 16:34 ` [PATCH 5/9] usb: xhci: " Geliang Tang
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Geliang Tang @ 2015-12-18 16:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Sergei Shtylyov; +Cc: Geliang Tang, linux-usb, linux-kernel

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/u132-hcd.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 05c85c7..43d5293 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -1309,13 +1309,9 @@ static void u132_hcd_ring_work_scheduler(struct work_struct *work)
 		u132_ring_put_kref(u132, ring);
 		return;
 	} else if (ring->curr_endp) {
-		struct u132_endp *last_endp = ring->curr_endp;
-		struct list_head *scan;
-		struct list_head *head = &last_endp->endp_ring;
+		struct u132_endp *endp, *last_endp = ring->curr_endp;
 		unsigned long wakeup = 0;
-		list_for_each(scan, head) {
-			struct u132_endp *endp = list_entry(scan,
-				struct u132_endp, endp_ring);
+		list_for_each_entry(endp, &last_endp->endp_ring, endp_ring) {
 			if (endp->queue_next == endp->queue_last) {
 			} else if ((endp->delayed == 0)
 				|| time_after_eq(jiffies, endp->jiffies)) {
@@ -2393,14 +2389,12 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 static int dequeue_from_overflow_chain(struct u132 *u132,
 	struct u132_endp *endp, struct urb *urb)
 {
-	struct list_head *scan;
-	struct list_head *head = &endp->urb_more;
-	list_for_each(scan, head) {
-		struct u132_urbq *urbq = list_entry(scan, struct u132_urbq,
-			urb_more);
+	struct u132_urbq *urbq;
+
+	list_for_each_entry(urbq, &endp->urb_more, urb_more) {
 		if (urbq->urb == urb) {
 			struct usb_hcd *hcd = u132_to_hcd(u132);
-			list_del(scan);
+			list_del(&urbq->urb_more);
 			endp->queue_size -= 1;
 			urb->error_count = 0;
 			usb_hcd_giveback_urb(hcd, urb, 0);
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/9] usb: xhci: use list_for_each_entry
  2015-12-18 16:34 [PATCH 1/9] usb: host: fotg210: use list_for_each_entry_safe Geliang Tang
                   ` (2 preceding siblings ...)
  2015-12-18 16:34 ` [PATCH 4/9] usb: host: u132-hcd: use list_for_each_entry Geliang Tang
@ 2015-12-18 16:34 ` Geliang Tang
  2015-12-18 16:34 ` [PATCH 6/9] usb: chipidea: debug: " Geliang Tang
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Geliang Tang @ 2015-12-18 16:34 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman; +Cc: Geliang Tang, linux-usb, linux-kernel

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/xhci-ring.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index f1c21c4..4ed15c0 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -640,7 +640,6 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id,
 	unsigned int ep_index;
 	struct xhci_ring *ep_ring;
 	struct xhci_virt_ep *ep;
-	struct list_head *entry;
 	struct xhci_td *cur_td = NULL;
 	struct xhci_td *last_unlinked_td;
 
@@ -670,8 +669,7 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id,
 	 * it.  We're also in the event handler, so we can't get re-interrupted
 	 * if another Stop Endpoint command completes
 	 */
-	list_for_each(entry, &ep->cancelled_td_list) {
-		cur_td = list_entry(entry, struct xhci_td, cancelled_td_list);
+	list_for_each_entry(cur_td, &ep->cancelled_td_list, cancelled_td_list) {
 		xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
 				"Removing canceled TD starting at 0x%llx (dma).",
 				(unsigned long long)xhci_trb_virt_to_dma(
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/9] usb: chipidea: debug: use list_for_each_entry
  2015-12-18 16:34 [PATCH 1/9] usb: host: fotg210: use list_for_each_entry_safe Geliang Tang
                   ` (3 preceding siblings ...)
  2015-12-18 16:34 ` [PATCH 5/9] usb: xhci: " Geliang Tang
@ 2015-12-18 16:34 ` 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
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Geliang Tang @ 2015-12-18 16:34 UTC (permalink / raw)
  To: Peter Chen, Greg Kroah-Hartman; +Cc: Geliang Tang, linux-usb, linux-kernel

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

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 drivers/usb/chipidea/debug.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index a4f7db2..de5c509 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -172,7 +172,6 @@ static int ci_requests_show(struct seq_file *s, void *data)
 {
 	struct ci_hdrc *ci = s->private;
 	unsigned long flags;
-	struct list_head   *ptr = NULL;
 	struct ci_hw_req *req = NULL;
 	struct td_node *node, *tmpnode;
 	unsigned i, j, qsize = sizeof(struct ci_hw_td)/sizeof(u32);
@@ -184,9 +183,7 @@ static int ci_requests_show(struct seq_file *s, void *data)
 
 	spin_lock_irqsave(&ci->lock, flags);
 	for (i = 0; i < ci->hw_ep_max; i++)
-		list_for_each(ptr, &ci->ci_hw_ep[i].qh.queue) {
-			req = list_entry(ptr, struct ci_hw_req, queue);
-
+		list_for_each_entry(req, &ci->ci_hw_ep[i].qh.queue, queue) {
 			list_for_each_entry_safe(node, tmpnode, &req->tds, td) {
 				seq_printf(s, "EP=%02i: TD=%08X %s\n",
 					   i % (ci->hw_ep_max / 2),
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/9] usb: dwc2: host: use list_for_each_entry_safe
  2015-12-18 16:34 [PATCH 1/9] usb: host: fotg210: use list_for_each_entry_safe Geliang Tang
                   ` (4 preceding siblings ...)
  2015-12-18 16:34 ` [PATCH 6/9] usb: chipidea: debug: " Geliang Tang
@ 2015-12-18 16:34 ` Geliang Tang
  2015-12-18 16:34 ` [PATCH 8/9] usb: gadget: rndis: " Geliang Tang
  2015-12-18 16:34 ` [PATCH 9/9] usb: gadget: bcm63xx_udc: " Geliang Tang
  7 siblings, 0 replies; 12+ messages in thread
From: Geliang Tang @ 2015-12-18 16:34 UTC (permalink / raw)
  To: John Youn, Greg Kroah-Hartman; +Cc: Geliang Tang, linux-usb, linux-kernel

Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 drivers/usb/dwc2/hcd_ddma.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc2/hcd_ddma.c b/drivers/usb/dwc2/hcd_ddma.c
index 36606fc..14e004d 100644
--- a/drivers/usb/dwc2/hcd_ddma.c
+++ b/drivers/usb/dwc2/hcd_ddma.c
@@ -1222,9 +1222,8 @@ static void dwc2_complete_non_isoc_xfer_ddma(struct dwc2_hsotg *hsotg,
 					     int chnum,
 					     enum dwc2_halt_status halt_status)
 {
-	struct list_head *qtd_item, *qtd_tmp;
 	struct dwc2_qh *qh = chan->qh;
-	struct dwc2_qtd *qtd = NULL;
+	struct dwc2_qtd *qtd = NULL, *tmp;
 	int xfer_done;
 	int desc_num = 0;
 
@@ -1234,10 +1233,9 @@ static void dwc2_complete_non_isoc_xfer_ddma(struct dwc2_hsotg *hsotg,
 		return;
 	}
 
-	list_for_each_safe(qtd_item, qtd_tmp, &qh->qtd_list) {
+	list_for_each_entry_safe(qtd, tmp, &qh->qtd_list, qtd_list_entry) {
 		int i;
 
-		qtd = list_entry(qtd_item, struct dwc2_qtd, qtd_list_entry);
 		xfer_done = 0;
 
 		for (i = 0; i < qtd->n_desc; i++) {
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/9] usb: gadget: rndis: use list_for_each_entry_safe
  2015-12-18 16:34 [PATCH 1/9] usb: host: fotg210: use list_for_each_entry_safe Geliang Tang
                   ` (5 preceding siblings ...)
  2015-12-18 16:34 ` [PATCH 7/9] usb: dwc2: host: use list_for_each_entry_safe Geliang Tang
@ 2015-12-18 16:34 ` Geliang Tang
  2015-12-22 18:07   ` Felipe Balbi
  2015-12-18 16:34 ` [PATCH 9/9] usb: gadget: bcm63xx_udc: " Geliang Tang
  7 siblings, 1 reply; 12+ messages in thread
From: Geliang Tang @ 2015-12-18 16:34 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Andrzej Pietrasiewicz
  Cc: Geliang Tang, linux-usb, linux-kernel

Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 drivers/usb/gadget/function/rndis.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
index 70d3917..34a76db 100644
--- a/drivers/usb/gadget/function/rndis.c
+++ b/drivers/usb/gadget/function/rndis.c
@@ -914,7 +914,7 @@ struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v)
 	params->media_state = RNDIS_MEDIA_STATE_DISCONNECTED;
 	params->resp_avail = resp_avail;
 	params->v = v;
-	INIT_LIST_HEAD(&(params->resp_queue));
+	INIT_LIST_HEAD(&params->resp_queue);
 	pr_debug("%s: configNr = %d\n", __func__, i);
 
 	return params;
@@ -1006,12 +1006,9 @@ EXPORT_SYMBOL_GPL(rndis_add_hdr);
 
 void rndis_free_response(struct rndis_params *params, u8 *buf)
 {
-	rndis_resp_t *r;
-	struct list_head *act, *tmp;
+	rndis_resp_t *r, *n;
 
-	list_for_each_safe(act, tmp, &(params->resp_queue))
-	{
-		r = list_entry(act, rndis_resp_t, list);
+	list_for_each_entry_safe(r, n, &params->resp_queue, list) {
 		if (r && r->buf == buf) {
 			list_del(&r->list);
 			kfree(r);
@@ -1022,14 +1019,11 @@ EXPORT_SYMBOL_GPL(rndis_free_response);
 
 u8 *rndis_get_next_response(struct rndis_params *params, u32 *length)
 {
-	rndis_resp_t *r;
-	struct list_head *act, *tmp;
+	rndis_resp_t *r, *n;
 
 	if (!length) return NULL;
 
-	list_for_each_safe(act, tmp, &(params->resp_queue))
-	{
-		r = list_entry(act, rndis_resp_t, list);
+	list_for_each_entry_safe(r, n, &params->resp_queue, list) {
 		if (!r->send) {
 			r->send = 1;
 			*length = r->length;
@@ -1053,7 +1047,7 @@ static rndis_resp_t *rndis_add_response(struct rndis_params *params, u32 length)
 	r->length = length;
 	r->send = 0;
 
-	list_add_tail(&r->list, &(params->resp_queue));
+	list_add_tail(&r->list, &params->resp_queue);
 	return r;
 }
 
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 9/9] usb: gadget: bcm63xx_udc: use list_for_each_entry_safe
  2015-12-18 16:34 [PATCH 1/9] usb: host: fotg210: use list_for_each_entry_safe Geliang Tang
                   ` (6 preceding siblings ...)
  2015-12-18 16:34 ` [PATCH 8/9] usb: gadget: rndis: " Geliang Tang
@ 2015-12-18 16:34 ` Geliang Tang
  7 siblings, 0 replies; 12+ messages in thread
From: Geliang Tang @ 2015-12-18 16:34 UTC (permalink / raw)
  To: Kevin Cernekee, Felipe Balbi, Greg Kroah-Hartman
  Cc: Geliang Tang, linux-usb, linux-kernel

Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 drivers/usb/gadget/udc/bcm63xx_udc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c
index 8cbb003..f5fccb3 100644
--- a/drivers/usb/gadget/udc/bcm63xx_udc.c
+++ b/drivers/usb/gadget/udc/bcm63xx_udc.c
@@ -1083,7 +1083,7 @@ static int bcm63xx_ep_disable(struct usb_ep *ep)
 	struct bcm63xx_ep *bep = our_ep(ep);
 	struct bcm63xx_udc *udc = bep->udc;
 	struct iudma_ch *iudma = bep->iudma;
-	struct list_head *pos, *n;
+	struct bcm63xx_req *breq, *n;
 	unsigned long flags;
 
 	if (!ep || !ep->desc)
@@ -1099,10 +1099,7 @@ static int bcm63xx_ep_disable(struct usb_ep *ep)
 	iudma_reset_channel(udc, iudma);
 
 	if (!list_empty(&bep->queue)) {
-		list_for_each_safe(pos, n, &bep->queue) {
-			struct bcm63xx_req *breq =
-				list_entry(pos, struct bcm63xx_req, queue);
-
+		list_for_each_entry_safe(breq, n, &bep->queue, queue) {
 			usb_gadget_unmap_request(&udc->gadget, &breq->req,
 						 iudma->is_tx);
 			list_del(&breq->queue);
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 8/9] usb: gadget: rndis: use list_for_each_entry_safe
  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
  0 siblings, 1 reply; 12+ messages in thread
From: Felipe Balbi @ 2015-12-22 18:07 UTC (permalink / raw)
  To: Geliang Tang, Greg Kroah-Hartman, Andrzej Pietrasiewicz
  Cc: Geliang Tang, linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 333 bytes --]


Hi,

Geliang Tang <geliangtang@163.com> writes:
> Use list_for_each_entry_safe() instead of list_for_each_safe() to
> simplify the code.
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>

there are other cleanups in this patch which shouldn't be here. Please
split and I'll apply for v4.6 merge window.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 8/9 v2] usb: gadget: rndis: use list_for_each_entry_safe
  2015-12-22 18:07   ` Felipe Balbi
@ 2015-12-23 13:51     ` Geliang Tang
  0 siblings, 0 replies; 12+ messages in thread
From: Geliang Tang @ 2015-12-23 13:51 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Andrzej Pietrasiewicz
  Cc: Geliang Tang, linux-usb, linux-kernel

Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 drivers/usb/gadget/function/rndis.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
index 70d3917..13280f5 100644
--- a/drivers/usb/gadget/function/rndis.c
+++ b/drivers/usb/gadget/function/rndis.c
@@ -1006,12 +1006,9 @@ EXPORT_SYMBOL_GPL(rndis_add_hdr);
 
 void rndis_free_response(struct rndis_params *params, u8 *buf)
 {
-	rndis_resp_t *r;
-	struct list_head *act, *tmp;
+	rndis_resp_t *r, *n;
 
-	list_for_each_safe(act, tmp, &(params->resp_queue))
-	{
-		r = list_entry(act, rndis_resp_t, list);
+	list_for_each_entry_safe(r, n, &params->resp_queue, list) {
 		if (r && r->buf == buf) {
 			list_del(&r->list);
 			kfree(r);
@@ -1022,14 +1019,11 @@ EXPORT_SYMBOL_GPL(rndis_free_response);
 
 u8 *rndis_get_next_response(struct rndis_params *params, u32 *length)
 {
-	rndis_resp_t *r;
-	struct list_head *act, *tmp;
+	rndis_resp_t *r, *n;
 
 	if (!length) return NULL;
 
-	list_for_each_safe(act, tmp, &(params->resp_queue))
-	{
-		r = list_entry(act, rndis_resp_t, list);
+	list_for_each_entry_safe(r, n, &params->resp_queue, list) {
 		if (!r->send) {
 			r->send = 1;
 			*length = r->length;
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 6/9] usb: chipidea: debug: use list_for_each_entry
  2015-12-18 16:34 ` [PATCH 6/9] usb: chipidea: debug: " Geliang Tang
@ 2015-12-25  7:41   ` Peter Chen
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Chen @ 2015-12-25  7:41 UTC (permalink / raw)
  To: Geliang Tang; +Cc: Peter Chen, Greg Kroah-Hartman, linux-usb, linux-kernel

On Sat, Dec 19, 2015 at 12:34:31AM +0800, Geliang Tang wrote:
> Use list_for_each_entry() instead of list_for_each() to simplify
> the code.
> 
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
>  drivers/usb/chipidea/debug.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
> index a4f7db2..de5c509 100644
> --- a/drivers/usb/chipidea/debug.c
> +++ b/drivers/usb/chipidea/debug.c
> @@ -172,7 +172,6 @@ static int ci_requests_show(struct seq_file *s, void *data)
>  {
>  	struct ci_hdrc *ci = s->private;
>  	unsigned long flags;
> -	struct list_head   *ptr = NULL;
>  	struct ci_hw_req *req = NULL;
>  	struct td_node *node, *tmpnode;
>  	unsigned i, j, qsize = sizeof(struct ci_hw_td)/sizeof(u32);
> @@ -184,9 +183,7 @@ static int ci_requests_show(struct seq_file *s, void *data)
>  
>  	spin_lock_irqsave(&ci->lock, flags);
>  	for (i = 0; i < ci->hw_ep_max; i++)
> -		list_for_each(ptr, &ci->ci_hw_ep[i].qh.queue) {
> -			req = list_entry(ptr, struct ci_hw_req, queue);
> -
> +		list_for_each_entry(req, &ci->ci_hw_ep[i].qh.queue, queue) {
>  			list_for_each_entry_safe(node, tmpnode, &req->tds, td) {
>  				seq_printf(s, "EP=%02i: TD=%08X %s\n",
>  					   i % (ci->hw_ep_max / 2),
> -- 
> 2.5.0
> 

It is ok for chipidea part, I will queue it, you don't need to
re-send it again

-- 

Best Regards,
Peter Chen

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-12-25  7:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-18 16:34 [PATCH 1/9] usb: host: fotg210: use list_for_each_entry_safe Geliang Tang
2015-12-18 16:34 ` [PATCH 2/9] usb: host: max3421-hcd: use list_for_each_entry* Geliang Tang
2015-12-18 16:34 ` [PATCH 3/9] usb: host: oxu210hp-hcd: use list_for_each_entry_safe 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox