[PATCH 2.5 17/25] 8390-cleanup for ne3210

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



make ne3210.c allocating the net_device's dynamically using the new
ei_alloc_dev() function, ethdev_init() is killed. compile tested.


--- 1.8/drivers/net/ne3210.c	Thu Nov 21 23:06:11 2002
+++ edited/ne3210.c	Sun Jun 29 21:38:06 2003
@@ -164,13 +164,6 @@
 	}
 #endif
 
-	/* Allocate dev->priv and fill in 8390 specific dev fields. */
-	if (ethdev_init(dev)) {
-		printk ("ne3210.c: unable to allocate memory for dev->priv!\n");
-		retval = -ENOMEM;
-		goto out;
-	}
-
 	printk("ne3210.c: NE3210 in EISA slot %d, media: %s, addr:",
 		ioaddr/0x1000, ifmap[inb(ioaddr + NE3210_CFG2) >> 6]);
 	for(i = 0; i < ETHER_ADDR_LEN; i++)
@@ -192,7 +185,7 @@
 	retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev);
 	if (retval) {
 		printk (" unable to get IRQ %d.\n", dev->irq);
-		goto out1;
+		goto out2;
 	}
 
 	if (dev->mem_start == 0) {
@@ -261,9 +254,6 @@
 	return 0;
 out2:
 	free_irq(dev->irq, dev);	
-out1:
-	kfree(dev->priv);
-	dev->priv = NULL;
 out:
 	release_region(ioaddr, NE3210_IO_EXTENT);
 	return retval;
@@ -362,7 +352,7 @@
 
 #ifdef MODULE
 #define MAX_NE3210_CARDS	4	/* Max number of NE3210 cards per module */
-static struct net_device dev_ne3210[MAX_NE3210_CARDS];
+static struct net_device *dev_ne3210[MAX_NE3210_CARDS];
 static int io[MAX_NE3210_CARDS];
 static int irq[MAX_NE3210_CARDS];
 static int mem[MAX_NE3210_CARDS];
@@ -381,14 +371,24 @@
 	int this_dev, found = 0;
 
 	for (this_dev = 0; this_dev < MAX_NE3210_CARDS; this_dev++) {
-		struct net_device *dev = &dev_ne3210[this_dev];
+		struct net_device *dev;
+
+		/* Default is to only install one card. */
+		if (io[this_dev] == 0 && this_dev != 0) break;
+
+		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];
 		dev->init = ne3210_probe;
-		/* 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 "ne3210.c: No NE3210 card found (i/o = 0x%x).\n", io[this_dev]);
 			if (found != 0) {	/* Got at least one. */
 				return 0;
@@ -396,6 +396,7 @@
 			return -ENXIO;
 		}
 		found++;
+		dev_ne3210[this_dev] = dev;
 	}
 	return 0;
 }
@@ -405,14 +406,14 @@
 	int this_dev;
 
 	for (this_dev = 0; this_dev < MAX_NE3210_CARDS; this_dev++) {
-		struct net_device *dev = &dev_ne3210[this_dev];
-		if (dev->priv != NULL) {
+		struct net_device *dev = dev_ne3210[this_dev];
+		if (dev) {
 			free_irq(dev->irq, dev);
 			release_region(dev->base_addr, NE3210_IO_EXTENT);
 			if (ei_status.reg0)
 				iounmap((void *)dev->mem_start);
 			unregister_netdev(dev);
-			kfree(dev->priv);
+			kfree(dev);
 			dev->priv = NULL;
 		}
 	}

-
: 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

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux