make hp.c allocating the net_device's dynamically using the new ei_alloc_dev() function, ethdev_init() is killed. compile tested. --- 1.8/drivers/net/hp.c Thu Nov 21 23:06:11 2002 +++ edited/hp.c Sun Jun 29 23:33:53 2003 @@ -131,13 +131,6 @@ if (ei_debug && version_printed++ == 0) printk(version); - /* Allocate dev->priv and fill in 8390 specific dev fields. */ - if (ethdev_init(dev)) { - printk (" unable to get memory for dev->priv.\n"); - retval = -ENOMEM; - goto out; - } - printk("%s: %s (ID %02x) at %#3x,", dev->name, name, board_id, ioaddr); for(i = 0; i < ETHER_ADDR_LEN; i++) @@ -166,14 +159,14 @@ if (*irqp == 0) { printk(" no free IRQ lines.\n"); retval = -EBUSY; - goto out1; + goto out; } } else { if (dev->irq == 2) dev->irq = 9; if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) { printk (" unable to get IRQ %d.\n", dev->irq); - goto out1; + goto out; } } @@ -195,9 +188,6 @@ hp_init_card(dev); return 0; -out1: - kfree(dev->priv); - dev->priv = NULL; out: release_region(ioaddr, HP_IO_EXTENT); return retval; @@ -206,8 +196,7 @@ static int hp_open(struct net_device *dev) { - ei_open(dev); - return 0; + return ei_open(dev); } static int @@ -372,7 +361,7 @@ #ifdef MODULE #define MAX_HP_CARDS 4 /* Max number of HP cards per module */ -static struct net_device dev_hp[MAX_HP_CARDS]; +static struct net_device *dev_hp[MAX_HP_CARDS]; static int io[MAX_HP_CARDS]; static int irq[MAX_HP_CARDS]; @@ -391,15 +380,24 @@ int this_dev, found = 0; for (this_dev = 0; this_dev < MAX_HP_CARDS; this_dev++) { - struct net_device *dev = &dev_hp[this_dev]; - dev->irq = irq[this_dev]; - dev->base_addr = io[this_dev]; - dev->init = hp_probe; + struct net_device *dev; if (io[this_dev] == 0) { if (this_dev != 0) break; /* only autoprobe 1st one */ printk(KERN_NOTICE "hp.c: Presently autoprobing (not recommended) for a single card.\n"); } + + dev = ei_alloc_dev(); + if (!dev) { + /* free already found devices */ + cleanup_module(); + return -ENOMEM; + } + + dev->irq = irq[this_dev]; + dev->base_addr = io[this_dev]; + dev->init = hp_probe; if (register_netdev(dev) != 0) { + kfree(dev); printk(KERN_WARNING "hp.c: No HP card found (i/o = 0x%x).\n", io[this_dev]); if (found != 0) { /* Got at least one. */ return 0; @@ -407,6 +405,7 @@ return -ENXIO; } found++; + dev_hp[this_dev] = dev; } return 0; } @@ -417,14 +416,13 @@ int this_dev; for (this_dev = 0; this_dev < MAX_HP_CARDS; this_dev++) { - struct net_device *dev = &dev_hp[this_dev]; - if (dev->priv != NULL) { + struct net_device *dev = dev_hp[this_dev]; + if (dev) { int ioaddr = dev->base_addr - NIC_OFFSET; - void *priv = dev->priv; free_irq(dev->irq, dev); release_region(ioaddr, HP_IO_EXTENT); unregister_netdev(dev); - kfree(priv); + kfree(dev); } } } - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html