[PATCH 2.5 16/25] 8390-cleanup for ne2k_cbus

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

 



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


--- 1.1/drivers/net/ne2k_cbus.h	Sun Dec 15 02:56:15 2002
+++ edited/ne2k_cbus.h	Sun Jun 29 19:14:52 2003
@@ -387,8 +387,6 @@
 	if (ei_local != NULL) {
 		if (ei_local->reg_offset)
 			kfree(ei_local->reg_offset);
-		kfree(dev->priv);
-		dev->priv = NULL;
 	}
 }
 
===== ne2k_cbus.c 1.1 vs edited =====
--- 1.1/drivers/net/ne2k_cbus.c	Sat Mar 15 04:37:35 2003
+++ edited/ne2k_cbus.c	Sun Jun 29 21:37:24 2003
@@ -476,14 +476,6 @@
 		goto err_out;
 	}
 
-	/* Allocate dev->priv and fill in 8390 specific dev fields. */
-	if (ethdev_init(dev))
-	{
-        	printk (" unable to get memory for dev->priv.\n");
-        	ret = -ENOMEM;
-		goto err_out;
-	}
-
 	/* Snarf the interrupt now.  There's no point in waiting since we cannot
 	   share and the board will usually be enabled. */
 	ret = request_irq(dev->irq, ei_interrupt, 0, name, dev);
@@ -798,7 +790,7 @@
 
 #ifdef MODULE
 #define MAX_NE_CARDS	4	/* Max number of NE cards per module */
-static struct net_device dev_ne[MAX_NE_CARDS];
+static struct net_device *dev_ne[MAX_NE_CARDS];
 static int io[MAX_NE_CARDS];
 static int irq[MAX_NE_CARDS];
 static int bad[MAX_NE_CARDS];	/* 0xbad = bad sig or no reset ack */
@@ -825,7 +817,13 @@
 	int this_dev, found = 0;
 
 	for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
-		struct net_device *dev = &dev_ne[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->mem_end = bad[this_dev];
 		dev->base_addr = io[this_dev];
@@ -833,8 +831,10 @@
 		dev->init = ne_probe;
 		if (register_netdev(dev) == 0) {
 			found++;
+			dev_ne[this_dev] = dev;
 			continue;
 		}
+		kfree(dev);
 		if (found != 0) { 	/* Got at least one. */
 			return 0;
 		}
@@ -852,8 +852,8 @@
 	int this_dev;
 
 	for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
-		struct net_device *dev = &dev_ne[this_dev];
-		if (dev->priv != NULL) {
+		struct net_device *dev = dev_ne[this_dev];
+		if (dev) {
 			const struct ne2k_cbus_region *rlist;
 			const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
 
@@ -864,6 +864,7 @@
 			}
 			unregister_netdev(dev);
 			ne2k_cbus_destroy(dev);
+			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