[PATCH 2.5 20/25] 8390-cleanup for smc-ultra

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

 



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


--- 1.16/drivers/net/smc-ultra.c	Tue Feb 25 20:50:51 2003
+++ edited/smc-ultra.c	Sun Jun 29 23:28:18 2003
@@ -226,13 +226,6 @@
 		eeprom_irq = 1;
 	}
 
-	/* Allocate dev->priv and fill in 8390 specific dev fields. */
-	if (ethdev_init(dev)) {
-		printk (", no memory for dev->priv.\n");
-                retval = -ENOMEM;
-		goto out;
-        }
-
 	/* The 8390 isn't at the base address, so fake the offset */
 	dev->base_addr = ioaddr+ULTRA_NIC_OFFSET;
 
@@ -352,8 +345,7 @@
 	   to receive ERW interrupts. */
 	outb_p(E8390_NODMA+E8390_PAGE0, dev->base_addr);
 	outb(0xff, dev->base_addr + EN0_ERWCNT);
-	ei_open(dev);
-	return 0;
+	return ei_open(dev);
 }
 
 static void
@@ -500,7 +492,7 @@
 
 #ifdef MODULE
 #define MAX_ULTRA_CARDS	4	/* Max number of Ultra cards per module */
-static struct net_device dev_ultra[MAX_ULTRA_CARDS];
+static struct net_device *dev_ultra[MAX_ULTRA_CARDS];
 static int io[MAX_ULTRA_CARDS];
 static int irq[MAX_ULTRA_CARDS];
 
@@ -519,20 +511,29 @@
 	int this_dev, found = 0;
 
 	for (this_dev = 0; this_dev < MAX_ULTRA_CARDS; this_dev++) {
-		struct net_device *dev = &dev_ultra[this_dev];
-		dev->irq = irq[this_dev];
-		dev->base_addr = io[this_dev];
-		dev->init = ultra_probe;
+		struct net_device *dev;
 		if (io[this_dev] == 0)  {
 			if (this_dev != 0) break; /* only autoprobe 1st one */
 			printk(KERN_NOTICE "smc-ultra.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 = ultra_probe;
 		if (register_netdev(dev) != 0) {
+			kfree(dev);
 			printk(KERN_WARNING "smc-ultra.c: No SMC Ultra card found (i/o = 0x%x).\n", io[this_dev]);
 			if (found != 0) return 0;	/* Got at least one. */
 			return -ENXIO;
 		}
 		found++;
+		dev_ultra[this_dev] = dev;
 	}
 
 	return 0;
@@ -544,8 +545,8 @@
 	int this_dev;
 
 	for (this_dev = 0; this_dev < MAX_ULTRA_CARDS; this_dev++) {
-		struct net_device *dev = &dev_ultra[this_dev];
-		if (dev->priv != NULL) {
+		struct net_device *dev = dev_ultra[this_dev];
+		if (dev) {
 			/* NB: ultra_close_card() does free_irq */
 			int ioaddr = dev->base_addr - ULTRA_NIC_OFFSET;
 
@@ -557,7 +558,7 @@
 
 			unregister_netdev(dev);
 			release_region(ioaddr, ULTRA_IO_EXTENT);
-			kfree(dev->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