netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@163.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Geliang Tang <geliangtang@163.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 05/14] atm: use list_for_each_entry
Date: Fri, 18 Dec 2015 23:33:29 +0800	[thread overview]
Message-ID: <e61fdf4b8da488ac268ecb89bb8e6e16a4e4c3bb.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() instead of list_for_each() to simplify
the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 net/atm/ioctl.c     | 5 ++---
 net/atm/resources.c | 8 ++------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c
index bbd3b63..9feb293 100644
--- a/net/atm/ioctl.c
+++ b/net/atm/ioctl.c
@@ -53,7 +53,7 @@ static int do_vcc_ioctl(struct socket *sock, unsigned int cmd,
 	struct sock *sk = sock->sk;
 	struct atm_vcc *vcc;
 	int error;
-	struct list_head *pos;
+	struct atm_ioctl *ic;
 	void __user *argp = (void __user *)arg;
 
 	vcc = ATM_SD(sock);
@@ -163,8 +163,7 @@ static int do_vcc_ioctl(struct socket *sock, unsigned int cmd,
 	error = -ENOIOCTLCMD;
 
 	mutex_lock(&ioctl_mutex);
-	list_for_each(pos, &ioctl_list) {
-		struct atm_ioctl *ic = list_entry(pos, struct atm_ioctl, list);
+	list_for_each_entry(ic, &ioctl_list, list) {
 		if (try_module_get(ic->owner)) {
 			error = ic->ioctl(sock, cmd, arg);
 			module_put(ic->owner);
diff --git a/net/atm/resources.c b/net/atm/resources.c
index 0447d5d..413d919 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -51,10 +51,8 @@ static struct atm_dev *__alloc_atm_dev(const char *type)
 static struct atm_dev *__atm_dev_lookup(int number)
 {
 	struct atm_dev *dev;
-	struct list_head *p;
 
-	list_for_each(p, &atm_devs) {
-		dev = list_entry(p, struct atm_dev, dev_list);
+	list_for_each_entry(dev, &atm_devs, dev_list) {
 		if (dev->number == number) {
 			atm_dev_hold(dev);
 			return dev;
@@ -238,10 +236,8 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat)
 			return -ENOMEM;
 		}
 		tmp_p = tmp_buf;
-		list_for_each(p, &atm_devs) {
-			dev = list_entry(p, struct atm_dev, dev_list);
+		list_for_each_entry(dev, &atm_devs, dev_list)
 			*tmp_p++ = dev->number;
-		}
 		mutex_unlock(&atm_dev_mutex);
 		error = ((copy_to_user(buf, tmp_buf, size)) ||
 			 put_user(size, iobuf_len))
-- 
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 ` Geliang Tang [this message]
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 ` [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=e61fdf4b8da488ac268ecb89bb8e6e16a4e4c3bb.1450451516.git.geliangtang@163.com \
    --to=geliangtang@163.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).