]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
MIPSnet: Modernize use platform_device API.
authorRalf Baechle <ralf@linux-mips.org>
Sun, 18 Mar 2007 23:21:22 +0000 (23:21 +0000)
committerJeff Garzik <jeff@garzik.org>
Sat, 28 Apr 2007 15:01:01 +0000 (11:01 -0400)
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
arch/mips/mips-boards/sim/Makefile
arch/mips/mips-boards/sim/sim_platform.c [new file with mode: 0644]
drivers/net/Kconfig
drivers/net/mipsnet.c

index 6aeebc9122f25ff96de48b107833a7a324a6de65..dc0bfda114277fa17a32d4f5280e345cb6b22a2f 100644 (file)
@@ -17,7 +17,8 @@
 # 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
 #
 
-obj-y := sim_setup.o sim_mem.o sim_time.o sim_int.o sim_cmdline.o
+obj-y := sim_platform.o sim_setup.o sim_mem.o sim_time.o sim_int.o \
+        sim_cmdline.o
 
 obj-$(CONFIG_EARLY_PRINTK) += sim_console.o
 obj-$(CONFIG_SMP) += sim_smp.o
diff --git a/arch/mips/mips-boards/sim/sim_platform.c b/arch/mips/mips-boards/sim/sim_platform.c
new file mode 100644 (file)
index 0000000..53210a8
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2007 by Ralf Baechle (ralf@linux-mips.org)
+ */
+#include <linux/init.h>
+#include <linux/if_ether.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+
+static char mipsnet_string[] = "mipsnet";
+
+static struct platform_device eth1_device = {
+       .name           = mipsnet_string,
+       .id             = 0,
+};
+
+/*
+ * Create a platform device for the GPI port that receives the
+ * image data from the embedded camera.
+ */
+static int __init mipsnet_devinit(void)
+{
+       int err;
+
+       err = platform_device_register(&eth1_device);
+       if (err)
+               printk(KERN_ERR "%s: registration failed\n", mipsnet_string);
+
+       return err;
+}
+
+device_initcall(mipsnet_devinit);
index 3e9b37055ea4c285c7fccbd9a08d5ab210d914d9..ee920ad1a5f5f51acb14ffe2b15be66d6a902252 100644 (file)
@@ -486,8 +486,8 @@ config SGI_IOC3_ETH_HW_TX_CSUM
          enables offloading for checksums on transmit.  If unsure, say Y.
 
 config MIPS_SIM_NET
-       tristate "MIPS simulator Network device (EXPERIMENTAL)"
-       depends on MIPS_SIM && EXPERIMENTAL
+       tristate "MIPS simulator Network device"
+       depends on NET_ETHERNET && MIPS_SIM
        help
          The MIPSNET device is a simple Ethernet network device which is
          emulated by the MIPS Simulator.
index 403f63afd20125ea7df272e51e4eaafd7a6c8382..638a279ec5051823a96819a95163dbd4383af7d6 100644 (file)
@@ -26,8 +26,6 @@ struct mipsnet_priv {
        struct net_device_stats stats;
 };
 
-static struct platform_device *mips_plat_dev;
-
 static char mipsnet_string[] = "mipsnet";
 
 /*
@@ -297,64 +295,17 @@ static struct device_driver mipsnet_driver = {
        .remove = __devexit_p(mipsnet_device_remove),
 };
 
-static void mipsnet_platform_release(struct device *device)
-{
-       struct platform_device *pldev;
-
-       /* free device */
-       pldev = to_platform_device(device);
-       kfree(pldev);
-}
-
 static int __init mipsnet_init_module(void)
 {
-       struct platform_device *pldev;
        int err;
 
        printk(KERN_INFO "MIPSNet Ethernet driver. Version: %s. "
               "(c)2005 MIPS Technologies, Inc.\n", MIPSNET_VERSION);
 
-       if (driver_register(&mipsnet_driver)) {
+       err = driver_register(&mipsnet_driver);
+       if (err)
                printk(KERN_ERR "Driver registration failed\n");
-               err = -ENODEV;
-               goto out;
-       }
-
-        if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) {
-               err = -ENOMEM;
-               goto out_unregister_driver;
-       }
-
-       memset (pldev, 0, sizeof (*pldev));
-       pldev->name             = mipsnet_string;
-       pldev->id               = 0;
-       pldev->dev.release      = mipsnet_platform_release;
 
-       if (platform_device_register(pldev)) {
-               err = -ENODEV;
-               goto out_free_pldev;
-       }
-
-        if (!pldev->dev.driver) {
-               /*
-                * The driver was not bound to this device, there was
-                 * no hardware at this address. Unregister it, as the
-                * release fuction will take care of freeing the
-                * allocated structure
-                */
-               platform_device_unregister (pldev);
-       }
-
-       mips_plat_dev           = pldev;
-
-       return 0;
-
-out_free_pldev:
-       kfree(pldev);
-
-out_unregister_driver:
-       driver_unregister(&mipsnet_driver);
-out:
        return err;
 }