From e971290133d8151c468cd70206fedc92648feb58 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 24 May 2007 12:54:04 +0100 Subject: 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 -- Fixes since previous patch: o Fixed typo in meth_exit_module() Signed-off-by: Jeff Garzik --- drivers/net/meth.c | 68 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 23 deletions(-) (limited to 'drivers/net') diff --git a/drivers/net/meth.c b/drivers/net/meth.c index 0343ea12b299..92b403bf38b0 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 -#include - -#include /* printk() */ #include +#include +#include +#include +#include +#include #include -#include /* error codes */ -#include /* size_t */ -#include /* mark_bh */ +#include +#include +#include #include #include @@ -33,7 +34,6 @@ #include #include -#include #include "meth.h" @@ -51,8 +51,6 @@ static const char *meth_str="SGI O2 Fast Ethernet"; -MODULE_AUTHOR("Ilya Volynets "); -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 "); +MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3