netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@163.com>
To: "David S. Miller" <davem@davemloft.net>,
	Jesper Dangaard Brouer <brouer@redhat.com>,
	Alexei Starovoitov <ast@plumgrid.com>
Cc: Geliang Tang <geliangtang@163.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 14/14] net: pktgen: use list_for_each_entry_safe
Date: Fri, 18 Dec 2015 23:33:38 +0800	[thread overview]
Message-ID: <7ed820c5b80db617d6f29aa8fe5ae00e899a83b2.1450451516.git.geliangtang@163.com> (raw)
In-Reply-To: <ab66a344512e064000357c6d3c2a6f3d0e948ddb.1450451516.git.geliangtang@163.com>
In-Reply-To: <ab66a344512e064000357c6d3c2a6f3d0e948ddb.1450451516.git.geliangtang@163.com>

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

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 net/core/pktgen.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 2be1444..1d8cffb 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3293,14 +3293,11 @@ static void pktgen_stop(struct pktgen_thread *t)
  */
 static void pktgen_rem_one_if(struct pktgen_thread *t)
 {
-	struct list_head *q, *n;
-	struct pktgen_dev *cur;
+	struct pktgen_dev *cur, *n;
 
 	func_enter();
 
-	list_for_each_safe(q, n, &t->if_list) {
-		cur = list_entry(q, struct pktgen_dev, list);
-
+	list_for_each_entry_safe(cur, n, &t->if_list, list) {
 		if (!cur->removal_mark)
 			continue;
 
@@ -3315,16 +3312,13 @@ static void pktgen_rem_one_if(struct pktgen_thread *t)
 
 static void pktgen_rem_all_ifs(struct pktgen_thread *t)
 {
-	struct list_head *q, *n;
-	struct pktgen_dev *cur;
+	struct pktgen_dev *cur, *n;
 
 	func_enter();
 
 	/* Remove all devices, free mem */
 
-	list_for_each_safe(q, n, &t->if_list) {
-		cur = list_entry(q, struct pktgen_dev, list);
-
+	list_for_each_entry_safe(cur, n, &t->if_list, list) {
 		kfree_skb(cur->skb);
 		cur->skb = NULL;
 
@@ -3771,12 +3765,10 @@ static int __net_init pktgen_create_thread(int cpu, struct pktgen_net *pn)
 static void _rem_dev_from_if_list(struct pktgen_thread *t,
 				  struct pktgen_dev *pkt_dev)
 {
-	struct list_head *q, *n;
-	struct pktgen_dev *p;
+	struct pktgen_dev *p, *n;
 
 	if_lock(t);
-	list_for_each_safe(q, n, &t->if_list) {
-		p = list_entry(q, struct pktgen_dev, list);
+	list_for_each_entry_safe(p, n, &t->if_list, list) {
 		if (p == pkt_dev)
 			list_del_rcu(&p->list);
 	}
@@ -3866,8 +3858,7 @@ remove:
 static void __net_exit pg_net_exit(struct net *net)
 {
 	struct pktgen_net *pn = net_generic(net, pg_net_id);
-	struct pktgen_thread *t;
-	struct list_head *q, *n;
+	struct pktgen_thread *t, *n;
 	LIST_HEAD(list);
 
 	/* Stop all interfaces & threads */
@@ -3877,8 +3868,7 @@ static void __net_exit pg_net_exit(struct net *net)
 	list_splice_init(&pn->pktgen_threads, &list);
 	mutex_unlock(&pktgen_thread_lock);
 
-	list_for_each_safe(q, n, &list) {
-		t = list_entry(q, struct pktgen_thread, th_list);
+	list_for_each_entry_safe(t, n, &list, th_list) {
 		list_del(&t->th_list);
 		kthread_stop(t->tsk);
 		put_task_struct(t->tsk);
-- 
2.5.0

  parent reply	other threads:[~2015-12-18 15:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18 15:33 [PATCH 01/14] Bluetooth: use list_for_each_entry* Geliang Tang
2015-12-18 15:33 ` [PATCH 02/14] sctp: " Geliang Tang
2015-12-18 15:52   ` Marcelo Ricardo Leitner
2015-12-18 15:33 ` [PATCH 03/14] ipv4, ipv6: " Geliang Tang
2015-12-18 15:33 ` [PATCH 04/14] x25: " Geliang Tang
2015-12-18 15:33 ` [PATCH 05/14] atm: use list_for_each_entry Geliang Tang
2015-12-18 15:33 ` [PATCH 06/14] libceph: use list_for_each_entry_safe Geliang Tang
2016-01-11 22:06   ` Ilya Dryomov
2015-12-18 15:33 ` [PATCH 07/14] batman-adv: " Geliang Tang
2015-12-21 14:42   ` Antonio Quartulli
2015-12-21 14:42   ` Antonio Quartulli
2016-03-28 15:02   ` [B.A.T.M.A.N.] " Marek Lindner
2015-12-18 15:33 ` [PATCH 08/14] caif: " Geliang Tang
2015-12-18 15:33 ` [PATCH 09/14] net: dsa: use list_for_each_entry Geliang Tang
2015-12-18 15:33 ` [PATCH 10/14] lapb: " Geliang Tang
     [not found] ` <ab66a344512e064000357c6d3c2a6f3d0e948ddb.1450451516.git.geliangtang-9Onoh4P/yGk@public.gmane.org>
2015-12-18 15:33   ` [PATCH 11/14] openvswitch: " Geliang Tang
2015-12-18 15:33 ` [PATCH 12/14] net: sched: " Geliang Tang
2015-12-18 15:33 ` [PATCH 13/14] sunrpc: use list_for_each_entry_safe Geliang Tang
2015-12-18 15:33 ` Geliang Tang [this message]
2015-12-20  7:13 ` [PATCH 01/14] Bluetooth: use list_for_each_entry* Marcel Holtmann

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=7ed820c5b80db617d6f29aa8fe5ae00e899a83b2.1450451516.git.geliangtang@163.com \
    --to=geliangtang@163.com \
    --cc=ast@plumgrid.com \
    --cc=brouer@redhat.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).