Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754159AbbLRPeG (ORCPT ); Fri, 18 Dec 2015 10:34:06 -0500 Received: from m50-134.163.com ([123.125.50.134]:34169 "EHLO m50-134.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754017AbbLRPd7 (ORCPT ); Fri, 18 Dec 2015 10:33:59 -0500 From: Geliang Tang To: "David S. Miller" Cc: Geliang Tang , 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 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: X-CM-TRANSID: DtGowEBJkkRgJ3RWMuIbAA--.8194S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cw45Wr1xGFy7JF4kXF1DZFb_yoW8ZF15pF 13C3W7trW8J3yIqrWkJa17ur1Sga4qg3yv9rWUC3WfXF4qyw48XF1fKw1Y9ry5GrWkuF1r Wa4qqF1Yqw4DGrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U5ManUUUUU= X-Originating-IP: [116.77.150.30] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiNQHUmVSIK4K91wAAsm Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2208 Lines: 69 Use list_for_each_entry() instead of list_for_each() to simplify the code. Signed-off-by: Geliang Tang --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/