[PATCH 2.5 1/25] alloc_etherdev in 8390.c

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

 



8390.c: introduce ei_alloc_dev() using alloc_etherdev to allocate net_device,
does the initialization as ethdev_init() does. kills ethdev_init().
compile tested.


--- 1.13/drivers/net/8390.c	Mon Apr 21 06:26:41 2003
+++ edited/8390.c	Tue Jul  1 00:16:10 2003
@@ -159,7 +159,7 @@
 	unsigned long flags;
 	struct ei_device *ei_local = (struct ei_device *) dev->priv;
 
-	/* This can't happen unless somebody forgot to call ethdev_init(). */
+	/* This can't happen unless somebody forgot to call ei_alloc_dev(). */
 	if (ei_local == NULL) 
 	{
 		printk(KERN_EMERG "%s: ei_open passed a non-existent device!\n", dev->name);
@@ -997,41 +997,31 @@
 	spin_unlock_irqrestore(&ei_local->page_lock, flags);
 }	
 
+
 /**
- * ethdev_init - init rest of 8390 device struct
- * @dev: network device structure to init
+ * ei_alloc_dev - allocates a struct net_device w/ 8390 specific private field
+ *  Do NOT __init this, as it is used by 8390 based modular drivers too.
  *
- * Initialize the rest of the 8390 device structure.  Do NOT __init
- * this, as it is used by 8390 based modular drivers too.
+ * return value: pointer to struct net_device
  */
-
-int ethdev_init(struct net_device *dev)
+struct net_device *ei_alloc_dev(void)
 {
-	if (ei_debug > 1)
-		printk(version);
-    
-	if (dev->priv == NULL) 
-	{
-		struct ei_device *ei_local;
-		
-		dev->priv = kmalloc(sizeof(struct ei_device), GFP_KERNEL);
-		if (dev->priv == NULL)
-			return -ENOMEM;
-		memset(dev->priv, 0, sizeof(struct ei_device));
-		ei_local = (struct ei_device *)dev->priv;
-		spin_lock_init(&ei_local->page_lock);
-	}
-    
+	struct net_device *dev;
+	struct ei_device *ei_local;
+
+	dev = alloc_etherdev(sizeof(struct ei_device));
+	if (!dev)
+		return NULL;
+
+	ei_local = (struct ei_device *)dev->priv;
+	spin_lock_init(&ei_local->page_lock);
+
 	dev->hard_start_xmit = &ei_start_xmit;
 	dev->get_stats	= get_stats;
 	dev->set_multicast_list = &set_multicast_list;
 
-	ether_setup(dev);
-        
-	return 0;
+	return dev;
 }
-
-
 
 /* This page of functions should be 8390 generic */
 /* Follow National Semi's recommendations for initializing the "NIC". */
@@ -1131,7 +1121,7 @@
 EXPORT_SYMBOL(ei_close);
 EXPORT_SYMBOL(ei_interrupt);
 EXPORT_SYMBOL(ei_tx_timeout);
-EXPORT_SYMBOL(ethdev_init);
+EXPORT_SYMBOL(ei_alloc_dev);
 EXPORT_SYMBOL(NS8390_init);
 
 #if defined(MODULE)
===== 8390.h 1.9 vs edited =====
--- 1.9/drivers/net/8390.h	Mon Apr 21 06:26:41 2003
+++ edited/8390.h	Tue Jul  1 00:14:57 2003
@@ -39,7 +39,7 @@
 #define ei_debug 1
 #endif
 
-extern int ethdev_init(struct net_device *dev);
+extern struct net_device *ei_alloc_dev(void);
 extern void NS8390_init(struct net_device *dev, int startp);
 extern int ei_open(struct net_device *dev);
 extern int ei_close(struct net_device *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