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