Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932538AbbLRPeP (ORCPT ); Fri, 18 Dec 2015 10:34:15 -0500 Received: from m50-138.163.com ([123.125.50.138]:36363 "EHLO m50-138.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754195AbbLRPeK (ORCPT ); Fri, 18 Dec 2015 10:34:10 -0500 From: Geliang Tang To: Dmitry Tarnyagin , "David S. Miller" Cc: Geliang Tang , 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 Message-Id: <9d0856e9713c935fe0df7449acbe6289c87e5d43.1450451516.git.geliangtang@163.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: X-CM-TRANSID: C9GowAD3HMRmJ3RW9j2mAA--.55186S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zw48ZFW8ZF13Ww13XFWDArb_yoW8XFW7pF WY9a43Gr4UX3ykuFsakF9Y9ry5XF1kJr43KryUCw1rtryDursrJan7WFy2vry5ZrWUu3s8 Wr4Dtr1rJrWxuFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U0tCcUUUUU= X-Originating-IP: [116.77.150.30] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiGQfUmVXlQAJglQAAsU Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1722 Lines: 55 Use list_for_each_entry_safe() instead of list_for_each_safe() to simplify the code. Signed-off-by: Geliang Tang --- 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 -- 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/