[PATCH 2.5 2/25] 8390-cleanup for 3c503

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

 



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


--- 1.13/drivers/net/3c503.c	Mon Feb 24 19:34:15 2003
+++ edited/3c503.c	Sun Jun 29 21:33:36 2003
@@ -191,13 +191,6 @@
 	printk(version);
 
     dev->base_addr = ioaddr;
-    /* Allocate dev->priv and fill in 8390 specific dev fields. */
-    if (ethdev_init(dev)) {
-	printk ("3c503: unable to allocate memory for dev->priv.\n");
-	retval = -ENOMEM;
-	goto out;
-    }
-
     printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
 
     /* Retrieve and print the ethernet address. */
@@ -361,8 +354,7 @@
     }
 
     el2_init_card(dev);
-    ei_open(dev);
-    return 0;
+    return ei_open(dev);
 }
 
 static int
@@ -684,7 +676,7 @@
 #ifdef MODULE
 #define MAX_EL2_CARDS	4	/* Max number of EL2 cards per module */
 
-static struct net_device dev_el2[MAX_EL2_CARDS];
+static struct net_device *dev_el2[MAX_EL2_CARDS];
 static int io[MAX_EL2_CARDS];
 static int irq[MAX_EL2_CARDS];
 static int xcvr[MAX_EL2_CARDS];	/* choose int. or ext. xcvr */
@@ -705,16 +697,25 @@
 	int this_dev, found = 0;
 
 	for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
-		struct net_device *dev = &dev_el2[this_dev];
-		dev->irq = irq[this_dev];
-		dev->base_addr = io[this_dev];
-		dev->mem_end = xcvr[this_dev];	/* low 4bits = xcvr sel. */
-		dev->init = el2_probe;
+		struct net_device *dev;
 		if (io[this_dev] == 0)  {
 			if (this_dev != 0) break; /* only autoprobe 1st one */
 			printk(KERN_NOTICE "3c503.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->mem_end = xcvr[this_dev];	/* low 4bits = xcvr sel. */
+		dev->init = el2_probe;
 		if (register_netdev(dev) != 0) {
+			kfree(dev);
 			printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
 			if (found != 0) {	/* Got at least one. */
 				return 0;
@@ -722,6 +723,7 @@
 			return -ENXIO;
 		}
 		found++;
+		dev_el2[this_dev] = dev;
 	}
 	return 0;
 }
@@ -732,13 +734,11 @@
 	int this_dev;
 
 	for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
-		struct net_device *dev = &dev_el2[this_dev];
-		if (dev->priv != NULL) {
-			void *priv = dev->priv;
-			/* NB: el2_close() handles free_irq */
+		struct net_device *dev = dev_el2[this_dev];
+		if (dev) {
 			release_region(dev->base_addr, EL2_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

[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