All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@163.com>
To: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>,
	"David S. Miller" <davem@davemloft.net>
Cc: Geliang Tang <geliangtang@163.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 08/14] caif: use list_for_each_entry_safe
Date: Fri, 18 Dec 2015 23:33:32 +0800	[thread overview]
Message-ID: <9d0856e9713c935fe0df7449acbe6289c87e5d43.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/caif/chnl_net.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
index 67a4a36..d3db77c 100644
--- a/net/caif/chnl_net.c
+++ b/net/caif/chnl_net.c
@@ -140,13 +140,10 @@ static int delete_device(struct chnl_net *dev)
 
 static void close_work(struct work_struct *work)
 {
-	struct chnl_net *dev = NULL;
-	struct list_head *list_node;
-	struct list_head *_tmp;
+	struct chnl_net *dev = NULL, *tmp;
 
 	rtnl_lock();
-	list_for_each_safe(list_node, _tmp, &chnl_net_list) {
-		dev = list_entry(list_node, struct chnl_net, list_field);
+	list_for_each_entry_safe(dev, tmp, &chnl_net_list, list_field) {
 		if (dev->state == CAIF_SHUTDOWN)
 			dev_close(dev->netdev);
 	}
@@ -535,14 +532,11 @@ static int __init chnl_init_module(void)
 
 static void __exit chnl_exit_module(void)
 {
-	struct chnl_net *dev = NULL;
-	struct list_head *list_node;
-	struct list_head *_tmp;
+	struct chnl_net *dev = NULL, *tmp;
 	rtnl_link_unregister(&ipcaif_link_ops);
 	rtnl_lock();
-	list_for_each_safe(list_node, _tmp, &chnl_net_list) {
-		dev = list_entry(list_node, struct chnl_net, list_field);
-		list_del(list_node);
+	list_for_each_entry_safe(dev, tmp, &chnl_net_list, list_field) {
+		list_del(&dev->list_field);
 		delete_device(dev);
 	}
 	rtnl_unlock();
-- 
2.5.0



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

Thread overview: 29+ 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:33   ` Geliang Tang
2015-12-18 15:52   ` Marcelo Ricardo Leitner
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-18 15:33   ` [B.A.T.M.A.N.] " Geliang Tang
2015-12-21 14:42   ` Antonio Quartulli
2015-12-21 14:42   ` Antonio Quartulli
2015-12-21 14:42   ` Antonio Quartulli
2015-12-21 14:42     ` [B.A.T.M.A.N.] " Antonio Quartulli
2016-03-10 19:37   ` Sven Eckelmann
2016-03-28 15:02   ` Marek Lindner
2016-03-28 15:02   ` Marek Lindner
2016-03-28 15:02     ` Marek Lindner
2015-12-18 15:33 ` Geliang Tang [this message]
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
2015-12-18 15:33 ` [PATCH 11/14] openvswitch: " Geliang Tang
2015-12-18 15:33   ` 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 ` [PATCH 14/14] net: pktgen: " Geliang Tang
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=9d0856e9713c935fe0df7449acbe6289c87e5d43.1450451516.git.geliangtang@163.com \
    --to=geliangtang@163.com \
    --cc=davem@davemloft.net \
    --cc=dmitry.tarnyagin@lockless.no \
    --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 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.