* [PATCH] slip: Remove the unused code and add some cleanups in slip.c
@ 2010-03-09 9:52 Li Hong
0 siblings, 0 replies; only message in thread
From: Li Hong @ 2010-03-09 9:52 UTC (permalink / raw)
To: David S. Miller, Andrew Morton; +Cc: linux-kernel
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@gmail.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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-03-09 9:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-09 9:52 [PATCH] slip: Remove the unused code and add some cleanups in slip.c Li Hong
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).