patch-2.1.31 linux/drivers/net/dummy.c

Next file: linux/drivers/net/eepro.c
Previous file: linux/drivers/net/de620.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.30/linux/drivers/net/dummy.c linux/drivers/net/dummy.c
@@ -29,7 +29,6 @@
 */
 
 /* To have statistics (just packets sent) define this */
-#undef DUMMY_STATS
 
 #include <linux/module.h>
 
@@ -54,9 +53,7 @@
 #include <linux/skbuff.h>
 
 static int dummy_xmit(struct sk_buff *skb, struct device *dev);
-#ifdef DUMMY_STATS
 static struct net_device_stats *dummy_get_stats(struct device *dev);
-#endif
 
 static int dummy_open(struct device *dev)
 {
@@ -70,26 +67,25 @@
 	return 0;
 }
 
+/* fake multicast ability */
+static void set_multicast_list(struct device *dev)
+{
+}
 
 int dummy_init(struct device *dev)
 {
-/* I commented this out as bootup is noisy enough anyway and this driver
-   seems pretty reliable 8) 8) 8) */
-/*	printk ( KERN_INFO "Dummy net driver (94/05/27 v1.0)\n" ); */
-
 	/* Initialize the device structure. */
 	dev->hard_start_xmit	= dummy_xmit;
 
-#if DUMMY_STATS
 	dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
 	if (dev->priv == NULL)
 		return -ENOMEM;
 	memset(dev->priv, 0, sizeof(struct net_device_stats));
 	dev->get_stats		= dummy_get_stats;
-#endif
 
 	dev->open = dummy_open;
 	dev->stop = dummy_close;
+	dev->set_multicast_list = set_multicast_list;
 
 	/* Fill in the fields of the device structure with ethernet-generic values. */
 	ether_setup(dev);
@@ -99,29 +95,23 @@
 	return 0;
 }
 
-static int
-dummy_xmit(struct sk_buff *skb, struct device *dev)
+static int dummy_xmit(struct sk_buff *skb, struct device *dev)
 {
-#if DUMMY_STATS
 	struct net_device_stats *stats;
-#endif
 	dev_kfree_skb(skb, FREE_WRITE);
 
-#if DUMMY_STATS
 	stats = (struct net_device_stats *)dev->priv;
 	stats->tx_packets++;
-#endif
+	stats->tx_bytes+=skb->len;
 
 	return 0;
 }
 
-#if DUMMY_STATS
 static struct net_device_stats *dummy_get_stats(struct device *dev)
 {
 	struct net_device_stats *stats = (struct net_device_stats *) dev->priv;
 	return stats;
 }
-#endif
 
 #ifdef MODULE
 
@@ -131,8 +121,10 @@
 	return 0;
 }
 
+static char dummy_name[16];
+
 static struct device dev_dummy = {
-	"dummy0\0   ", 
+		dummy_name, 	/* Needs to be writeable */
 		0, 0, 0, 0,
 	 	0x0, 0,
 	 	0, 0, 0, NULL, dummy_probe };
@@ -140,16 +132,9 @@
 int init_module(void)
 {
 	/* Find a name for this unit */
-	int ct= 1;
-	
-	while(dev_get(dev_dummy.name)!=NULL && ct<100)
-	{
-		sprintf(dev_dummy.name,"dummy%d",ct);
-		ct++;
-	}
-	if(ct==100)
-		return -ENFILE;
-	
+	int err=dev_alloc_name(&dev_dummy,"dummy%d");
+	if(err)
+		return err;
 	if (register_netdev(&dev_dummy) != 0)
 		return -EIO;
 	return 0;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov