From: Andrew Morton <andrewm@uow.edu.au>
To: Jeff Garzik <jgarzik@mandrakesoft.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
netdev@oss.sgi.com, Linus Torvalds <torvalds@transmeta.com>,
"David S. Miller" <davem@redhat.com>
Subject: Re: PATCH 2.4.3.6: fix netdevice initialization
Date: Thu, 22 Mar 2001 02:21:18 +1100 [thread overview]
Message-ID: <3AB8C6EE.5EF6BA90@uow.edu.au> (raw)
In-Reply-To: <3AB8BA16.A25C0929@mandrakesoft.com>
Jeff Garzik wrote:
>
> Attached is a patch against 2.4.3-pre6, which adds alloc_etherdev and
> variants to the driver API.
Looks good. Few minor things:
In register_netdev():
if (strchr(dev->name, '%'))
{
err = -EBUSY;
if(dev_alloc_name(dev, dev->name)<0)
goto out;
}
We should propagate dev_alloc_name's return value:
err = dev_alloc_name()
if (err < 0)
goto out;
And register_netdevice's, so
err = -EIO;
if (register_netdevice(dev))
goto out;
err = 0;
out:
becomes simply
err = register_netdevice(dev);
out:
More significantly, the driver probe functions now become:
xxx_probe()
{
dev = alloc_etherdev(sizeof(xxx_private));
...
printk(KERN_INFO "%s: stuff\n", dev->name);
...
ret = register_netdev(dev);
if (ret < 0)
kfree(ret);
return ret;
}
yes?
And the printk() will say "eth%d: stuff", so we'll need to
change the messages:
- printk(KERN_INFO "%s: stuff\n", dev->name);
+ printk(KERN_INFO "xxx: stuff\n");
Correct?
My quibble with this is things like wait_for_completion(),
which are called from both the probe() function and
the mainline driver code. These also print dev->name,
and there's no obvious fix for that.
For this reason I think I'd prefer it if alloc_etherdev()
was passed some probe-time identifier:
alloc_etherdev(sizeof(xxx_private), "xxx");
which goes into dev->name, and gets overwritten by
register_netdev().
So, against your current patch:
--- drivers/net/net_init.c.orig Thu Mar 22 02:11:47 2001
+++ drivers/net/net_init.c Thu Mar 22 02:17:46 2001
@@ -71,7 +71,7 @@
static struct net_device *alloc_netdev(int sizeof_priv, const char *mask,
- void (*setup)(struct net_device *))
+ const char *driver_name, void (*setup)(struct net_device *))
{
struct net_device *dev;
int alloc_size;
@@ -92,7 +92,8 @@
dev->priv = (void *) (((long)(dev + 1) + 31) & ~31);
setup(dev);
- strcpy(dev->name, mask);
+ strcpy(dev->ifname, mask);
+ strcpy(dev->name, driver_name);
return dev;
}
@@ -216,9 +217,9 @@
* this private data area.
*/
-struct net_device *alloc_etherdev(int sizeof_priv)
+struct net_device *alloc_etherdev(int sizeof_priv, const char *driver_name)
{
- return alloc_netdev(sizeof_priv, "eth%d", ether_setup);
+ return alloc_netdev(sizeof_priv, "eth%d", driver_name, ether_setup);
}
EXPORT_SYMBOL(init_etherdev);
@@ -532,7 +533,7 @@
int register_netdev(struct net_device *dev)
{
- int err;
+ int err = 0;
rtnl_lock();
@@ -540,13 +541,14 @@
* If the name is a format string the caller wants us to
* do a name allocation
*/
-
- if (strchr(dev->name, '%'))
- {
- err = -EBUSY;
- if(dev_alloc_name(dev, dev->name)<0)
- goto out;
- }
+
+ /* Insert comment here */
+ if (strchr(dev->ifname, '%'))
+ err = dev_alloc_name(dev, dev->ifname);
+ else if (strchr(dev->name, '%'))
+ err = dev_alloc_name(dev, dev->name);
+ if (err < 0)
+ goto out;
/*
* Back compatibility hook. Kill this one in 2.5
next prev parent reply other threads:[~2001-03-21 15:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-21 14:26 PATCH 2.4.3.6: fix netdevice initialization Jeff Garzik
2001-03-21 14:33 ` Jeff Garzik
2001-03-21 15:21 ` Andrew Morton [this message]
2001-03-21 15:41 ` Jeff Garzik
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=3AB8C6EE.5EF6BA90@uow.edu.au \
--to=andrewm@uow.edu.au \
--cc=davem@redhat.com \
--cc=jgarzik@mandrakesoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@oss.sgi.com \
--cc=torvalds@transmeta.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