Skip to contentSkip to conversation

Init code for ppc405 enet

PATCH David Gibson 1 participant 1 message Sep 6, 2001 Network drivers

lore
Share & tools
lore
#0 lore raw

The following patch adds module init code to the ppc405 enet driver, so that it no longer needs additions to Space.c to be initialised.

drivers/net/ppc405_enet.c renamed from linuxppc_2_4_devel/drivers/net/ppc405_enet.c +24 -22
diff -urN ../linuxppc_2_4_devel/drivers/net/ppc405_enet.c linux-bungo/drivers/net/ppc405_enet.c
@@ -31,6 +31,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/string.h>
@@ -54,7 +55,6 @@
 
 #include "ppc405_enet.h"
 
-int		ppc405_enet_probe(struct net_device *);
 static int	ppc405_enet_probe1(struct net_device *);
 static int	ppc405_phy_speed(void);
 static int	ppc405_phy_duplex(void);
@@ -95,27 +95,7 @@
 static volatile int	ppc405_enet_ack_slot = 0;
 static volatile int	ppc405_enet_rx_slot = 0;
 
-
-/*
- * Maintain the initial probe as a sub function just in case it is wished
- * to have this driver as a module later.
- */
-int ppc405_enet_probe_done = 0;
-
-
-
-int
-ppc405_enet_probe(struct net_device *dev)
-{
-	if (ppc405_enet_probe_done)
-		return -ENODEV;
-
-	ppc405_enet_probe1(dev);
-
-	ppc405_enet_probe_done = 1;
-	return 0;
-}
-
+static struct net_device ppc405_enet_dev;
 
 static int
 ppc405_enet_open(struct net_device *dev)
@@ -1265,6 +1245,28 @@
 	return  crc_value;
 }
 
+static int __init init_ppc405_enet(void)
+{
+	int rc;
+
+	rc = ppc405_enet_probe1(&ppc405_enet_dev);
+	if (rc)
+		return rc;
+
+	rc = register_netdev(&ppc405_enet_dev);
+	if (rc)
+		return rc;
+
+	return 0;
+}
+
+static void __exit exit_ppc405_enet(void)
+{
+	unregister_netdev(&ppc405_enet_dev);
+}
+
+module_init(init_ppc405_enet);
+module_exit(exit_ppc405_enet);
 
 /*
  * Local variables:

--
David Gibson | For every complex problem there is a
[email protected] | solution which is simple, neat and
| wrong. -- H.L. Mencken
http://www.ozlabs.org/people/dgibson

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/