[PATCH 2.5 21/25] 8390-cleanup for smc-ultra32

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

 



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


--- 1.7/drivers/net/smc-ultra32.c	Thu Nov 21 23:06:12 2002
+++ edited/smc-ultra32.c	Sun Jun 29 23:28:34 2003
@@ -209,13 +209,6 @@
 		dev->irq = irq;
 	}
 
-	/* 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 + ULTRA32_NIC_OFFSET;
 
@@ -268,8 +261,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 int ultra32_close(struct net_device *dev)
@@ -379,7 +371,7 @@
 
 #ifdef MODULE
 #define MAX_ULTRA32_CARDS   4	/* Max number of Ultra cards per module */
-static struct net_device dev_ultra[MAX_ULTRA32_CARDS];
+static struct net_device *dev_ultra[MAX_ULTRA32_CARDS];
 
 MODULE_DESCRIPTION("SMC Ultra32 EISA ethernet driver");
 MODULE_LICENSE("GPL");
@@ -389,9 +381,16 @@
 	int this_dev, found = 0;
 
 	for (this_dev = 0; this_dev < MAX_ULTRA32_CARDS; this_dev++) {
-		struct net_device *dev = &dev_ultra[this_dev];
+		struct net_device *dev = ei_alloc_dev();
+		if (!dev) {
+			/* free already found devices */
+			cleanup_module();
+			return -ENOMEM;
+		}
+
 		dev->init = ultra32_probe;
 		if (register_netdev(dev) != 0) {
+			kfree(dev);
 			if (found > 0) { /* Got at least one. */
 				return 0;
 			}
@@ -399,6 +398,7 @@
 			return -ENXIO;
 		}
 		found++;
+		dev_ultra[this_dev] = dev;
 	}
 	return 0;
 }
@@ -408,14 +408,13 @@
 	int this_dev;
 
 	for (this_dev = 0; this_dev < MAX_ULTRA32_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) {
 			int ioaddr = dev->base_addr - ULTRA32_NIC_OFFSET;
-			void *priv = dev->priv;
 			/* NB: ultra32_close_card() does free_irq */
 			release_region(ioaddr, ULTRA32_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