make ac3200.c allocating the net_device's dynamically using the new ei_alloc_dev() function, ethdev_init() is killed. compile tested. --- 1.12/drivers/net/ac3200.c Wed Apr 23 09:49:34 2003 +++ edited/ac3200.c Sun Jun 29 21:21:48 2003 @@ -155,13 +155,6 @@ } #endif - /* Allocate dev->priv and fill in 8390 specific dev fields. */ - if (ethdev_init(dev)) { - printk (", unable to allocate memory for dev->priv.\n"); - retval = -ENOMEM; - goto out; - } - /* Assign and allocate the interrupt now. */ if (dev->irq == 0) { dev->irq = config2irq(inb(ioaddr + AC_CONFIG)); @@ -174,7 +167,7 @@ retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev); if (retval) { printk (" nothing! Unable to get IRQ %d.\n", dev->irq); - goto out1; + goto out2; } printk(" IRQ %d, %s port\n", dev->irq, port_name[dev->if_port]); @@ -248,9 +241,6 @@ return 0; out2: free_irq(dev->irq, dev); -out1: - kfree(dev->priv); - dev->priv = NULL; out: release_region(ioaddr, AC_IO_EXTENT); return retval; @@ -263,8 +253,7 @@ int ioaddr = dev->base_addr; #endif - ei_open(dev); - return 0; + return ei_open(dev); } static void ac_reset_8390(struct net_device *dev) @@ -337,7 +326,7 @@ #ifdef MODULE #define MAX_AC32_CARDS 4 /* Max number of AC32 cards per module */ -static struct net_device dev_ac32[MAX_AC32_CARDS]; +static struct net_device *dev_ac32[MAX_AC32_CARDS]; static int io[MAX_AC32_CARDS]; static int irq[MAX_AC32_CARDS]; static int mem[MAX_AC32_CARDS]; @@ -356,7 +345,13 @@ int this_dev, found = 0; for (this_dev = 0; this_dev < MAX_AC32_CARDS; this_dev++) { - struct net_device *dev = &dev_ac32[this_dev]; + struct net_device *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->mem_start = mem[this_dev]; /* Currently ignored by driver */ @@ -364,6 +359,7 @@ /* Default is to only install one card. */ if (io[this_dev] == 0 && this_dev != 0) break; if (register_netdev(dev) != 0) { + kfree(dev); printk(KERN_WARNING "ac3200.c: No ac3200 card found (i/o = 0x%x).\n", io[this_dev]); if (found != 0) { /* Got at least one. */ return 0; @@ -371,6 +367,7 @@ return -ENXIO; } found++; + dev_ac32[this_dev] = dev; } return 0; } @@ -381,16 +378,15 @@ int this_dev; for (this_dev = 0; this_dev < MAX_AC32_CARDS; this_dev++) { - struct net_device *dev = &dev_ac32[this_dev]; - if (dev->priv != NULL) { + struct net_device *dev = dev_ac32[this_dev]; + if (dev) { /* Someday free_irq may be in ac_close_card() */ free_irq(dev->irq, dev); release_region(dev->base_addr, AC_IO_EXTENT); if (ei_status.reg0) iounmap((void *)dev->mem_start); unregister_netdev(dev); - kfree(dev->priv); - dev->priv = NULL; + 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