提交 1e2b980f 编写于 作者: R Ralf Baechle 提交者: Jeff Garzik

MIPSnet: Modernize use platform_device API.

Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
Signed-off-by: NJeff Garzik <jeff@garzik.org>
上级 a5f8f3b6
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. # 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_EARLY_PRINTK) += sim_console.o
obj-$(CONFIG_SMP) += sim_smp.o obj-$(CONFIG_SMP) += sim_smp.o
/*
* 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);
...@@ -486,8 +486,8 @@ config SGI_IOC3_ETH_HW_TX_CSUM ...@@ -486,8 +486,8 @@ config SGI_IOC3_ETH_HW_TX_CSUM
enables offloading for checksums on transmit. If unsure, say Y. enables offloading for checksums on transmit. If unsure, say Y.
config MIPS_SIM_NET config MIPS_SIM_NET
tristate "MIPS simulator Network device (EXPERIMENTAL)" tristate "MIPS simulator Network device"
depends on MIPS_SIM && EXPERIMENTAL depends on NET_ETHERNET && MIPS_SIM
help help
The MIPSNET device is a simple Ethernet network device which is The MIPSNET device is a simple Ethernet network device which is
emulated by the MIPS Simulator. emulated by the MIPS Simulator.
......
...@@ -26,8 +26,6 @@ struct mipsnet_priv { ...@@ -26,8 +26,6 @@ struct mipsnet_priv {
struct net_device_stats stats; struct net_device_stats stats;
}; };
static struct platform_device *mips_plat_dev;
static char mipsnet_string[] = "mipsnet"; static char mipsnet_string[] = "mipsnet";
/* /*
...@@ -297,64 +295,17 @@ static struct device_driver mipsnet_driver = { ...@@ -297,64 +295,17 @@ static struct device_driver mipsnet_driver = {
.remove = __devexit_p(mipsnet_device_remove), .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) static int __init mipsnet_init_module(void)
{ {
struct platform_device *pldev;
int err; int err;
printk(KERN_INFO "MIPSNet Ethernet driver. Version: %s. " printk(KERN_INFO "MIPSNet Ethernet driver. Version: %s. "
"(c)2005 MIPS Technologies, Inc.\n", MIPSNET_VERSION); "(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"); 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; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册