diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2007-05-24 12:54:04 +0100 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-05-24 17:20:49 -0400 |
commit | e971290133d8151c468cd70206fedc92648feb58 (patch) | |
tree | dde9ebfd2a269dd892782c73910255a422a872a5 /drivers/net/meth.c | |
parent | 73815538e642de66a5607cc16d13004ecb1a3062 (diff) | |
download | op-kernel-dev-e971290133d8151c468cd70206fedc92648feb58.zip op-kernel-dev-e971290133d8151c468cd70206fedc92648feb58.tar.gz |
meth driver renovation
The meth ethernet driver for the SGI IP32 aka O2 is so far still an old
style driver which does not use the device driver model. This is now
causing issues with some udev based gadgetry in debian-stable. Fixed by
converting the meth driver to a platform device.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
--
Fixes since previous patch:
o Fixed typo in meth_exit_module()
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/meth.c')
-rw-r--r-- | drivers/net/meth.c | 68 |
1 files changed, 45 insertions, 23 deletions
diff --git a/drivers/net/meth.c b/drivers/net/meth.c index 0343ea1..92b403b 100644 --- a/drivers/net/meth.c +++ b/drivers/net/meth.c @@ -8,15 +8,16 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ -#include <linux/module.h> -#include <linux/init.h> - -#include <linux/kernel.h> /* printk() */ #include <linux/delay.h> +#include <linux/dma-mapping.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/platform_device.h> #include <linux/slab.h> -#include <linux/errno.h> /* error codes */ -#include <linux/types.h> /* size_t */ -#include <linux/interrupt.h> /* mark_bh */ +#include <linux/errno.h> +#include <linux/types.h> +#include <linux/interrupt.h> #include <linux/in.h> #include <linux/in6.h> @@ -33,7 +34,6 @@ #include <asm/io.h> #include <asm/scatterlist.h> -#include <linux/dma-mapping.h> #include "meth.h" @@ -51,8 +51,6 @@ static const char *meth_str="SGI O2 Fast Ethernet"; -MODULE_AUTHOR("Ilya Volynets <ilya@theIlya.com>"); -MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver"); #define HAVE_TX_TIMEOUT /* The maximum time waited (in jiffies) before assuming a Tx failed. (400ms) */ @@ -784,15 +782,15 @@ static struct net_device_stats *meth_stats(struct net_device *dev) /* * The init function. */ -static struct net_device *meth_init(void) +static int __init meth_probe(struct platform_device *pdev) { struct net_device *dev; struct meth_private *priv; - int ret; + int err; dev = alloc_etherdev(sizeof(struct meth_private)); if (!dev) - return ERR_PTR(-ENOMEM); + return -ENOMEM; dev->open = meth_open; dev->stop = meth_release; @@ -808,11 +806,12 @@ static struct net_device *meth_init(void) priv = netdev_priv(dev); spin_lock_init(&priv->meth_lock); + SET_NETDEV_DEV(dev, &pdev->dev); - ret = register_netdev(dev); - if (ret) { + err = register_netdev(dev); + if (err) { free_netdev(dev); - return ERR_PTR(ret); + return err; } printk(KERN_INFO "%s: SGI MACE Ethernet rev. %d\n", @@ -820,21 +819,44 @@ static struct net_device *meth_init(void) return 0; } -static struct net_device *meth_dev; +static int __exit meth_remove(struct platform_device *pdev) +{ + struct net_device *dev = platform_get_drvdata(pdev); + + unregister_netdev(dev); + free_netdev(dev); + platform_set_drvdata(pdev, NULL); + + return 0; +} + +static struct platform_driver meth_driver = { + .probe = meth_probe, + .remove = __devexit_p(meth_remove), + .driver = { + .name = "meth", + } +}; static int __init meth_init_module(void) { - meth_dev = meth_init(); - if (IS_ERR(meth_dev)) - return PTR_ERR(meth_dev); - return 0; + int err; + + err = platform_driver_register(&meth_driver); + if (err) + printk(KERN_ERR "Driver registration failed\n"); + + return err; } static void __exit meth_exit_module(void) { - unregister_netdev(meth_dev); - free_netdev(meth_dev); + platform_driver_unregister(&meth_driver); } module_init(meth_init_module); module_exit(meth_exit_module); + +MODULE_AUTHOR("Ilya Volynets <ilya@theIlya.com>"); +MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver"); +MODULE_LICENSE("GPL"); |