[patch 1/3] systemsim: cleanup systemsim network patch

Eric Van Hensbergen ericvh at gmail.com
Sat Feb 4 01:55:06 EST 2006


Subject: [PATCH] systemsim: clean-up systemsim network patch

Incorporate some of the LKML feedback, clean-up naming conventions and fix
a bogus free in the close routine.

Signed-off-by: Eric Van Hensbergen <bergevan at us.ibm.com>

---

 drivers/net/systemsim_net.c |  113 ++++++++++++++++++++++---------------------
 1 files changed, 57 insertions(+), 56 deletions(-)

79e30c5718a29c6de20e45f00bc1b458b359c29c
diff --git a/drivers/net/systemsim_net.c b/drivers/net/systemsim_net.c
index babc1fb..0a4cea9 100644
--- a/drivers/net/systemsim_net.c
+++ b/drivers/net/systemsim_net.c
@@ -60,32 +60,32 @@
 #include <linux/version.h>
 #include <asm/systemsim.h>
 
-#define MAMBO_BOGUS_NET_PROBE   119
-#define MAMBO_BOGUS_NET_SEND    120
-#define MAMBO_BOGUS_NET_RECV    121
+#define SYSTEMSIM_NET_PROBE   119
+#define SYSTEMSIM_NET_SEND    120
+#define SYSTEMSIM_NET_RECV    121
 
-static inline int MamboBogusNetProbe(int devno, void *buf)
+static inline int systemsim_bogusnet_probe(int devno, void *buf)
 {
-	return callthru2(MAMBO_BOGUS_NET_PROBE,
+	return callthru2(SYSTEMSIM_NET_PROBE,
 			 (unsigned long)devno, (unsigned long)buf);
 }
 
-static inline int MamboBogusNetSend(int devno, void *buf, ulong size)
+static inline int systemsim_bogusnet_send(int devno, void *buf, ulong size)
 {
-	return callthru3(MAMBO_BOGUS_NET_SEND,
+	return callthru3(SYSTEMSIM_NET_SEND,
 			 (unsigned long)devno,
 			 (unsigned long)buf, (unsigned long)size);
 }
 
-static inline int MamboBogusNetRecv(int devno, void *buf, ulong size)
+static inline int systemsim_bogusnet_recv(int devno, void *buf, ulong size)
 {
-	return callthru3(MAMBO_BOGUS_NET_RECV,
+	return callthru3(SYSTEMSIM_NET_RECV,
 			 (unsigned long)devno,
 			 (unsigned long)buf, (unsigned long)size);
 }
 
 static irqreturn_t
-mambonet_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+systemsim_net_intr(int irq, void *dev_instance, struct pt_regs *regs);
 
 #define INIT_BOTTOM_HALF(x,y,z) INIT_WORK(x, y, (void*)z)
 #define SCHEDULE_BOTTOM_HALF(x) schedule_delayed_work(x, 1)
@@ -100,18 +100,18 @@ struct netdev_private {
 	struct net_device_stats stats;
 };
 
-static int mambonet_probedev(int devno, void *buf)
+static int systemsim_net_probedev(int devno, void *buf)
 {
-	struct device_node *mambo;
+	struct device_node *systemsim;
 	struct device_node *net;
 	unsigned int *reg;
 
-	mambo = find_path_device("/mambo");
+	systemsim = find_path_device("/systemsim");
 
-	if (mambo == NULL) {
+	if (systemsim == NULL) {
 		return -1;
 	}
-	net = find_path_device("/mambo/bogus-net at 0");
+	net = find_path_device("/systemsim/bogus-net at 0");
 	if (net == NULL) {
 		return -1;
 	}
@@ -121,20 +121,20 @@ static int mambonet_probedev(int devno, 
 		return -1;
 	}
 
-	return MamboBogusNetProbe(devno, buf);
+	return systemsim_bogusnet_probe(devno, buf);
 }
 
-static int mambonet_send(int devno, void *buf, ulong size)
+static int systemsim_net_send(int devno, void *buf, ulong size)
 {
-	return MamboBogusNetSend(devno, buf, size);
+	return systemsim_bogusnet_send(devno, buf, size);
 }
 
-static int mambonet_recv(int devno, void *buf, ulong size)
+static int systemsim_net_recv(int devno, void *buf, ulong size)
 {
-	return MamboBogusNetRecv(devno, buf, size);
+	return systemsim_bogusnet_recv(devno, buf, size);
 }
 
-static int mambonet_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static int systemsim_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct netdev_private *priv = (struct netdev_private *)dev->priv;
 	int devno = priv->devno;
@@ -142,7 +142,7 @@ static int mambonet_start_xmit(struct sk
 	skb->dev = dev;
 
 	/* we might need to checksum or something */
-	mambonet_send(devno, skb->data, skb->len);
+	systemsim_net_send(devno, skb->data, skb->len);
 
 	dev->last_rx = jiffies;
 	priv->stats.rx_bytes += skb->len;
@@ -155,7 +155,7 @@ static int mambonet_start_xmit(struct sk
 	return (0);
 }
 
-static int mambonet_poll(struct net_device *dev, int *budget)
+static int systemsim_net_poll(struct net_device *dev, int *budget)
 {
 	struct netdev_private *np = dev->priv;
 	int devno = np->devno;
@@ -166,7 +166,7 @@ static int mambonet_poll(struct net_devi
 	int max_frames = min(*budget, dev->quota);
 	int ret = 0;
 
-	while ((ns = mambonet_recv(devno, buffer, 1600)) > 0) {
+	while ((ns = systemsim_net_recv(devno, buffer, 1600)) > 0) {
 		if ((skb = dev_alloc_skb(ns + 2)) != NULL) {
 			skb->dev = dev;
 			skb_reserve(skb, 2);	/* 16 byte align the IP
@@ -209,12 +209,12 @@ static int mambonet_poll(struct net_devi
 	return ret;
 }
 
-static void mambonet_timer(struct net_device *dev)
+static void systemsim_net_timer(struct net_device *dev)
 {
 	int budget = 16;
 	struct netdev_private *priv = (struct netdev_private *)dev->priv;
 
-	mambonet_poll(dev, &budget);
+	systemsim_net_poll(dev, &budget);
 
 	if (!priv->closing) {
 		SCHEDULE_BOTTOM_HALF(&priv->poll_task);
@@ -228,7 +228,7 @@ static struct net_device_stats *get_stat
 }
 
 static irqreturn_t
-mambonet_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+systemsim_net_intr(int irq, void *dev_instance, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_instance;
 	if (netif_rx_schedule_prep(dev)) {
@@ -237,7 +237,7 @@ mambonet_interrupt(int irq, void *dev_in
 	return IRQ_HANDLED;
 }
 
-static int mambonet_open(struct net_device *dev)
+static int systemsim_net_open(struct net_device *dev)
 {
 	struct netdev_private *priv;
 	int ret = 0;
@@ -245,29 +245,30 @@ static int mambonet_open(struct net_devi
 	priv = dev->priv;
 
 	/*
-	 * we can't start polling in mambonet_init, because I don't think
+	 * we can't start polling in systemsim_net_init, because I don't think
 	 * workqueues are usable that early. so start polling now.
 	 */
 
 	if (dev->irq) {
-		ret = request_irq(dev->irq, &mambonet_interrupt, 0,
+		ret = request_irq(dev->irq, &systemsim_net_intr, 0,
 				  dev->name, dev);
 
 		if (ret == 0) {
 			netif_start_queue(dev);
 		} else {
-			printk(KERN_ERR "mambonet: request irq failed\n");
+			printk(KERN_ERR "systemsim net: request irq failed\n");
 		}
 
-		MamboBogusNetProbe(priv->devno, NULL);	/* probe with NULL to activate interrupts */
+		/* probe with NULL to activate interrupts */
+		systemsim_bogusnet_probe(priv->devno, NULL);	
 	} else {
-		mambonet_timer(dev);
+		systemsim_net_timer(dev);
 	}
 
 	return ret;
 }
 
-static int mambonet_close(struct net_device *dev)
+static int systemsim_net_close(struct net_device *dev)
 {
 	struct netdev_private *priv;
 
@@ -282,30 +283,29 @@ static int mambonet_close(struct net_dev
 		KILL_BOTTOM_HALF(&priv->poll_task);
 	}
 
-	kfree(priv);
-
 	return 0;
 }
 
-static struct net_device_stats mambonet_stats;
+static struct net_device_stats systemsim_net_stats;
 
-static struct net_device_stats *mambonet_get_stats(struct net_device *dev)
+static struct net_device_stats *systemsim_net_get_stats(struct net_device *dev)
 {
-	return &mambonet_stats;
+	return &systemsim_net_stats;
 }
 
-static int mambonet_set_mac_address(struct net_device *dev, void *p)
+static int systemsim_net_set_mac_address(struct net_device *dev, void *p)
 {
 	return -EOPNOTSUPP;
 }
-static int mambonet_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static int systemsim_net_ioctl(struct net_device *dev, struct ifreq *ifr,
+			       int cmd)
 {
 	return -EOPNOTSUPP;
 }
 static int nextdevno = 0;	/* running count of device numbers */
 
 /* Initialize the rest of the device. */
-int __init do_mambonet_probe(struct net_device *dev)
+int __init do_systemsim_net_probe(struct net_device *dev)
 {
 	struct netdev_private *priv;
 	int devno = nextdevno++;
@@ -313,7 +313,7 @@ int __init do_mambonet_probe(struct net_
 
 	printk("eth%d: bogus network driver initialization\n", devno);
 
-	irq = mambonet_probedev(devno, dev->dev_addr);
+	irq = systemsim_net_probedev(devno, dev->dev_addr);
 
 	if (irq < 0) {
 		printk("No IRQ retreived\n");
@@ -328,14 +328,14 @@ int __init do_mambonet_probe(struct net_
 
 	dev->irq = irq;
 	dev->mtu = MAMBO_MTU;
-	dev->open = mambonet_open;
-	dev->poll = mambonet_poll;
+	dev->open = systemsim_net_open;
+	dev->poll = systemsim_net_poll;
 	dev->weight = 16;
-	dev->stop = mambonet_close;
-	dev->hard_start_xmit = mambonet_start_xmit;
-	dev->get_stats = mambonet_get_stats;
-	dev->set_mac_address = mambonet_set_mac_address;
-	dev->do_ioctl = mambonet_ioctl;
+	dev->stop = systemsim_net_close;
+	dev->hard_start_xmit = systemsim_net_start_xmit;
+	dev->get_stats = systemsim_net_get_stats;
+	dev->set_mac_address = systemsim_net_set_mac_address;
+	dev->do_ioctl = systemsim_net_ioctl;
 
 	dev->priv = kmalloc(sizeof(struct netdev_private), GFP_KERNEL);
 	if (dev->priv == NULL)
@@ -348,14 +348,14 @@ int __init do_mambonet_probe(struct net_
 	dev->get_stats = get_stats;
 
 	if (dev->irq == 0) {
-		INIT_BOTTOM_HALF(&priv->poll_task, (void *)mambonet_timer,
+		INIT_BOTTOM_HALF(&priv->poll_task, (void *)systemsim_net_timer,
 				 (void *)dev);
 	}
 
 	return (0);
 };
 
-struct net_device *__init mambonet_probe(int unit)
+struct net_device *__init systemsim_net_probe(int unit)
 {
 	struct net_device *dev = alloc_etherdev(0);
 	int err;
@@ -366,7 +366,7 @@ struct net_device *__init mambonet_probe
 	sprintf(dev->name, "eth%d", unit);
 	netdev_boot_setup_check(dev);
 
-	err = do_mambonet_probe(dev);
+	err = do_systemsim_net_probe(dev);
 
 	if (err)
 		goto out;
@@ -382,11 +382,12 @@ struct net_device *__init mambonet_probe
 	return ERR_PTR(err);
 }
 
-int __init init_mambonet(void)
+int __init init_systemsim_net(void)
 {
-	mambonet_probe(0);
+	systemsim_net_probe(0);
 	return 0;
 }
 
-module_init(init_mambonet);
+module_init(init_systemsim_net);
+MODULE_DESCRIPTION("Systemsim Network Driver");
 MODULE_LICENSE("GPL");
-- 
1.0.GIT



More information about the Linuxppc64-dev mailing list