[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20100309095255.GA10793@xhl>
Date: Tue, 9 Mar 2010 17:52:55 +0800
From: Li Hong <lihong.hi@...il.com>
To: "David S. Miller" <davem@...emloft.net>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] slip: Remove the unused code and add some cleanups in
slip.c
In sl_alloc(), after the for block:
for (i = 0; i < slip_maxdev; i++) {
dev = slip_devs[i];
if (dev == NULL)
break;
}
The result is either i >= slip_maxdev or dev != NULL. So the following check
on dev is needless.
Signed-off-by: Li Hong <lihong.hi@...il.com>
---
drivers/net/slip.c | 24 +++++++-----------------
1 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index ba5bbc5..adf89c0 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -737,24 +737,15 @@ static struct slip *sl_alloc(dev_t line)
if (i >= slip_maxdev)
return NULL;
- if (dev) {
- sl = netdev_priv(dev);
- if (test_bit(SLF_INUSE, &sl->flags)) {
- unregister_netdevice(dev);
- dev = NULL;
- slip_devs[i] = NULL;
- }
- }
+ char name[IFNAMSIZ];
+ sprintf(name, "sl%d", i);
- if (!dev) {
- char name[IFNAMSIZ];
- sprintf(name, "sl%d", i);
+ dev = alloc_netdev(sizeof(*sl), name, sl_setup);
+ if (!dev)
+ return NULL;
- dev = alloc_netdev(sizeof(*sl), name, sl_setup);
- if (!dev)
- return NULL;
- dev->base_addr = i;
- }
+ dev->base_addr = i;
+ slip_devs[i] = dev;
sl = netdev_priv(dev);
@@ -772,7 +763,6 @@ static struct slip *sl_alloc(dev_t line)
sl->outfill_timer.data = (unsigned long)sl;
sl->outfill_timer.function = sl_outfill;
#endif
- slip_devs[i] = dev;
return sl;
}
--
1.6.3.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists