From 019904d0dee2a4bf329f1778551dda0b3686a83a Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 14 Oct 2003 05:40:23 -0400 Subject: [PATCH] [PATCH] Fix pcnet_cs network hotplug pcnet_cs registers the network device too early. The effect of this is that the networking hotplug scripts are unable to bring the device up automatically. There are two issues: - we were registering the net device before we finished setting up the device (eg, reading the MAC address.) - we were using DEV_CONFIG_PENDING to block the net device "open" callback, and as we know the other methods may be called prior to open. My only concern with this patch is that we set info->node.dev_name after we register the net device, so use of cardctl during the hotplug scripts may give unexpected results. However, I am not aware of anyone using cardctl to read the device name in network hotplug scripts. Please review and merge. Thanks. --- drivers/net/pcmcia/pcnet_cs.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index d6bcac3b173e8..c52f1c1627103 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -681,10 +681,6 @@ static void pcnet_config(dev_link_t *link) } else { dev->if_port = 0; } - if (register_netdev(dev) != 0) { - printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n"); - goto failed; - } hw_info = get_hwinfo(link); if (hw_info == NULL) @@ -699,7 +695,6 @@ static void pcnet_config(dev_link_t *link) if (hw_info == NULL) { printk(KERN_NOTICE "pcnet_cs: unable to read hardware net" " address for io base %#3lx\n", dev->base_addr); - unregister_netdev(dev); goto failed; } @@ -733,8 +728,6 @@ static void pcnet_config(dev_link_t *link) ei_status.word16 = 1; ei_status.reset_8390 = &pcnet_reset_8390; - strcpy(info->node.dev_name, dev->name); - link->dev = &info->node; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); if (info->flags & (IS_DL10019|IS_DL10022)) { @@ -743,6 +736,21 @@ static void pcnet_config(dev_link_t *link) mii_phy_probe(dev); if ((id == 0x30) && !info->pna_phy && (info->eth_phy == 4)) info->eth_phy = 0; + } + + link->dev = &info->node; + link->state &= ~DEV_CONFIG_PENDING; + + if (register_netdev(dev) != 0) { + printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n"); + link->dev = NULL; + goto failed; + } + + strcpy(info->node.dev_name, dev->name); + + if (info->flags & (IS_DL10019|IS_DL10022)) { + u_char id = inb(dev->base_addr + 0x1a); printk(KERN_INFO "%s: NE2000 (DL100%d rev %02x): ", dev->name, ((info->flags & IS_DL10022) ? 22 : 19), id); if (info->pna_phy) @@ -758,7 +766,6 @@ static void pcnet_config(dev_link_t *link) printk(" hw_addr "); for (i = 0; i < 6; i++) printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); - link->state &= ~DEV_CONFIG_PENDING; return; cs_failed: -- 2.53.0