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>

authored by

Ralf Baechle and committed by
Jeff Garzik
e9712901 73815538

+66 -24
+1 -1
arch/mips/sgi-ip32/Makefile
··· 3 # under Linux. 4 # 5 6 - obj-y += ip32-berr.o ip32-irq.o ip32-setup.o ip32-reset.o \ 7 crime.o ip32-memory.o
··· 3 # under Linux. 4 # 5 6 + obj-y += ip32-berr.o ip32-irq.o ip32-platform.o ip32-setup.o ip32-reset.o \ 7 crime.o ip32-memory.o
+20
arch/mips/sgi-ip32/ip32-platform.c
···
··· 1 + #include <linux/init.h> 2 + #include <linux/platform_device.h> 3 + 4 + static __init int meth_devinit(void) 5 + { 6 + struct platform_device *pd; 7 + int ret; 8 + 9 + pd = platform_device_alloc("meth", -1); 10 + if (!pd) 11 + return -ENOMEM; 12 + 13 + ret = platform_device_add(pd); 14 + if (ret) 15 + platform_device_put(pd); 16 + 17 + return ret; 18 + } 19 + 20 + device_initcall(meth_devinit);
+45 -23
drivers/net/meth.c
··· 8 * as published by the Free Software Foundation; either version 9 * 2 of the License, or (at your option) any later version. 10 */ 11 - #include <linux/module.h> 12 - #include <linux/init.h> 13 - 14 - #include <linux/kernel.h> /* printk() */ 15 #include <linux/delay.h> 16 #include <linux/slab.h> 17 - #include <linux/errno.h> /* error codes */ 18 - #include <linux/types.h> /* size_t */ 19 - #include <linux/interrupt.h> /* mark_bh */ 20 21 #include <linux/in.h> 22 #include <linux/in6.h> ··· 34 35 #include <asm/io.h> 36 #include <asm/scatterlist.h> 37 - #include <linux/dma-mapping.h> 38 39 #include "meth.h" 40 ··· 51 52 53 static const char *meth_str="SGI O2 Fast Ethernet"; 54 - MODULE_AUTHOR("Ilya Volynets <ilya@theIlya.com>"); 55 - MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver"); 56 57 #define HAVE_TX_TIMEOUT 58 /* The maximum time waited (in jiffies) before assuming a Tx failed. (400ms) */ ··· 782 /* 783 * The init function. 784 */ 785 - static struct net_device *meth_init(void) 786 { 787 struct net_device *dev; 788 struct meth_private *priv; 789 - int ret; 790 791 dev = alloc_etherdev(sizeof(struct meth_private)); 792 if (!dev) 793 - return ERR_PTR(-ENOMEM); 794 795 dev->open = meth_open; 796 dev->stop = meth_release; ··· 806 807 priv = netdev_priv(dev); 808 spin_lock_init(&priv->meth_lock); 809 810 - ret = register_netdev(dev); 811 - if (ret) { 812 free_netdev(dev); 813 - return ERR_PTR(ret); 814 } 815 816 printk(KERN_INFO "%s: SGI MACE Ethernet rev. %d\n", ··· 819 return 0; 820 } 821 822 - static struct net_device *meth_dev; 823 824 static int __init meth_init_module(void) 825 { 826 - meth_dev = meth_init(); 827 - if (IS_ERR(meth_dev)) 828 - return PTR_ERR(meth_dev); 829 - return 0; 830 } 831 832 static void __exit meth_exit_module(void) 833 { 834 - unregister_netdev(meth_dev); 835 - free_netdev(meth_dev); 836 } 837 838 module_init(meth_init_module); 839 module_exit(meth_exit_module);
··· 8 * as published by the Free Software Foundation; either version 9 * 2 of the License, or (at your option) any later version. 10 */ 11 #include <linux/delay.h> 12 + #include <linux/dma-mapping.h> 13 + #include <linux/init.h> 14 + #include <linux/kernel.h> 15 + #include <linux/module.h> 16 + #include <linux/platform_device.h> 17 #include <linux/slab.h> 18 + #include <linux/errno.h> 19 + #include <linux/types.h> 20 + #include <linux/interrupt.h> 21 22 #include <linux/in.h> 23 #include <linux/in6.h> ··· 33 34 #include <asm/io.h> 35 #include <asm/scatterlist.h> 36 37 #include "meth.h" 38 ··· 51 52 53 static const char *meth_str="SGI O2 Fast Ethernet"; 54 55 #define HAVE_TX_TIMEOUT 56 /* The maximum time waited (in jiffies) before assuming a Tx failed. (400ms) */ ··· 784 /* 785 * The init function. 786 */ 787 + static int __init meth_probe(struct platform_device *pdev) 788 { 789 struct net_device *dev; 790 struct meth_private *priv; 791 + int err; 792 793 dev = alloc_etherdev(sizeof(struct meth_private)); 794 if (!dev) 795 + return -ENOMEM; 796 797 dev->open = meth_open; 798 dev->stop = meth_release; ··· 808 809 priv = netdev_priv(dev); 810 spin_lock_init(&priv->meth_lock); 811 + SET_NETDEV_DEV(dev, &pdev->dev); 812 813 + err = register_netdev(dev); 814 + if (err) { 815 free_netdev(dev); 816 + return err; 817 } 818 819 printk(KERN_INFO "%s: SGI MACE Ethernet rev. %d\n", ··· 820 return 0; 821 } 822 823 + static int __exit meth_remove(struct platform_device *pdev) 824 + { 825 + struct net_device *dev = platform_get_drvdata(pdev); 826 + 827 + unregister_netdev(dev); 828 + free_netdev(dev); 829 + platform_set_drvdata(pdev, NULL); 830 + 831 + return 0; 832 + } 833 + 834 + static struct platform_driver meth_driver = { 835 + .probe = meth_probe, 836 + .remove = __devexit_p(meth_remove), 837 + .driver = { 838 + .name = "meth", 839 + } 840 + }; 841 842 static int __init meth_init_module(void) 843 { 844 + int err; 845 + 846 + err = platform_driver_register(&meth_driver); 847 + if (err) 848 + printk(KERN_ERR "Driver registration failed\n"); 849 + 850 + return err; 851 } 852 853 static void __exit meth_exit_module(void) 854 { 855 + platform_driver_unregister(&meth_driver); 856 } 857 858 module_init(meth_init_module); 859 module_exit(meth_exit_module); 860 + 861 + MODULE_AUTHOR("Ilya Volynets <ilya@theIlya.com>"); 862 + MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver"); 863 + MODULE_LICENSE("GPL");