netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Savochkin <saw@swsoft.com>
To: netdev@vger.kernel.org
Cc: Kirill Korotaev <dev@openvz.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	Gerald Schaefer <gerald.schaefer@de.ibm.com>,
	schwidefsky@de.ibm.com, davem@davemloft.net, ecashin@coraid.com,
	matthew@wil.cx
Subject: [patch 5/7] net_device list cleanup: arch-dependent code and block devices
Date: Mon, 3 Jul 2006 12:18:55 +0400	[thread overview]
Message-ID: <20060630164944.G22285@castle.nmd.msu.ru> (raw)
In-Reply-To: <20060630150823.A22285@castle.nmd.msu.ru>; from "Andrey Savochkin" on Fri, Jun 30, 2006 at 03:08:23PM

Cleanup of net_device list use in arch-dependent code and block devices.

The cleanup consists of
 - converting the to list_head, to make the list double-linked (thus making
   remove operation O(1)), and list walks more readable;
 - introducing of for_each_netdev wrapper over list_for_each.

Signed-off-by: Andrey Savochkin <saw@swsoft.com>
---
 arch/s390/appldata/appldata_net_sum.c |    2 +-
 arch/sparc64/solaris/ioctl.c          |    2 +-
 drivers/block/aoe/aoecmd.c            |    8 ++++++--
 drivers/parisc/led.c                  |    2 +-
 4 files changed, 9 insertions(+), 5 deletions(-)

--- ./arch/s390/appldata/appldata_net_sum.c.vedevbase-misc	Mon Jul  3 15:13:15 2006
+++ ./arch/s390/appldata/appldata_net_sum.c	Mon Jul  3 16:16:05 2006
@@ -107,7 +107,7 @@ static void appldata_get_net_sum_data(vo
 	tx_dropped = 0;
 	collisions = 0;
 	read_lock(&dev_base_lock);
-	for (dev = dev_base; dev != NULL; dev = dev->next) {
+	for_each_netdev(dev) {
 		if (dev->get_stats == NULL) {
 			continue;
 		}
--- ./arch/sparc64/solaris/ioctl.c.vedevbase-misc	Mon Mar 20 08:53:29 2006
+++ ./arch/sparc64/solaris/ioctl.c	Mon Jul  3 16:16:05 2006
@@ -686,7 +686,7 @@ static inline int solaris_i(unsigned int
 			int i = 0;
 			
 			read_lock_bh(&dev_base_lock);
-			for (d = dev_base; d; d = d->next) i++;
+			for_each_netdev(d) i++;
 			read_unlock_bh(&dev_base_lock);
 
 			if (put_user (i, (int __user *)A(arg)))
--- ./drivers/block/aoe/aoecmd.c.vedevbase-misc	Mon Jul  3 15:09:57 2006
+++ ./drivers/block/aoe/aoecmd.c	Mon Jul  3 16:16:05 2006
@@ -204,14 +204,17 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigne
 	sl = sl_tail = NULL;
 
 	read_lock(&dev_base_lock);
-	for (ifp = dev_base; ifp; dev_put(ifp), ifp = ifp->next) {
+	for_each_netdev(ifp) {
 		dev_hold(ifp);
-		if (!is_aoe_netif(ifp))
+		if (!is_aoe_netif(ifp)) {
+			dev_put(ifp);
 			continue;
+		}
 
 		skb = new_skb(ifp, sizeof *h + sizeof *ch);
 		if (skb == NULL) {
 			printk(KERN_INFO "aoe: aoecmd_cfg: skb alloc failure\n");
+			dev_put(ifp);
 			continue;
 		}
 		if (sl_tail == NULL)
@@ -229,6 +232,7 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigne
 
 		skb->next = sl;
 		sl = skb;
+		dev_put(ifp);
 	}
 	read_unlock(&dev_base_lock);
 
--- ./drivers/parisc/led.c.vedevbase-misc	Mon Jul  3 15:13:46 2006
+++ ./drivers/parisc/led.c	Mon Jul  3 16:16:05 2006
@@ -367,7 +367,7 @@ static __inline__ int led_get_net_activi
 	 * for reading should be OK */
 	read_lock(&dev_base_lock);
 	rcu_read_lock();
-	for (dev = dev_base; dev; dev = dev->next) {
+	for_each_netdev(dev) {
 	    struct net_device_stats *stats;
 	    struct in_device *in_dev = __in_dev_get_rcu(dev);
 	    if (!in_dev || !in_dev->ifa_list)

  parent reply	other threads:[~2006-07-03 16:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-03  8:18 [patch 1/7] net_device list cleanup: core Andrey Savochkin
2006-07-03  8:18 ` [patch 2/7] net_device list cleanup: proc seq_file output Andrey Savochkin
2006-07-03  8:18 ` [patch 3/7] net_device list cleanup: netlink_dump Andrey Savochkin
2006-07-03  8:18 ` [patch 4/7] net_device list cleanup: drivers and non-IP protocols Andrey Savochkin
2006-07-07 19:18   ` Stephen Hemminger
2006-07-03  8:18 ` Andrey Savochkin [this message]
2006-07-03  8:18 ` [patch 6/7] net_device list cleanup: dev_base removal Andrey Savochkin
2006-07-03  8:18 ` [patch 7/7] net_device list cleanup: debugging Andrey Savochkin
2006-07-03 17:46 ` [patch 1/7] net_device list cleanup: core Christoph Hellwig
2006-07-04  7:24   ` Andrey Savochkin
2006-07-04  9:10     ` Christoph Hellwig
2006-07-04 14:50       ` Andrey Savochkin
2006-07-04 16:35         ` Alexey Kuznetsov
2006-07-05  8:26           ` Andrey Savochkin
2006-07-07  4:34 ` YOSHIFUJI Hideaki / 吉藤英明
2006-07-07  7:54   ` Andrey Savochkin
2006-07-07 16:48     ` YOSHIFUJI Hideaki / 吉藤英明
2006-07-10  6:53       ` Andrey Savochkin

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=20060630164944.G22285@castle.nmd.msu.ru \
    --to=saw@swsoft.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvz.org \
    --cc=ebiederm@xmission.com \
    --cc=ecashin@coraid.com \
    --cc=gerald.schaefer@de.ibm.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=matthew@wil.cx \
    --cc=netdev@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    /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).