From: Li Hong <lihong.hi@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] slip: Remove the unused code and add some cleanups in slip.c
Date: Tue, 9 Mar 2010 17:52:55 +0800 [thread overview]
Message-ID: <20100309095255.GA10793@xhl> (raw)
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
reply other threads:[~2010-03-09 9:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20100309095255.GA10793@xhl \
--to=lihong.hi@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.