diff options
Diffstat (limited to 'drivers')
-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 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 | ||
53 | static const char *meth_str="SGI O2 Fast Ethernet"; | 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 | 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 | */ |
787 | static struct net_device *meth_init(void) | 785 | static 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 | ||
823 | static struct net_device *meth_dev; | 822 | static 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 | |||
833 | static struct platform_driver meth_driver = { | ||
834 | .probe = meth_probe, | ||
835 | .remove = __devexit_p(meth_remove), | ||
836 | .driver = { | ||
837 | .name = "meth", | ||
838 | } | ||
839 | }; | ||
824 | 840 | ||
825 | static int __init meth_init_module(void) | 841 | static 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 | ||
833 | static void __exit meth_exit_module(void) | 852 | static 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 | ||
839 | module_init(meth_init_module); | 857 | module_init(meth_init_module); |
840 | module_exit(meth_exit_module); | 858 | module_exit(meth_exit_module); |
859 | |||
860 | MODULE_AUTHOR("Ilya Volynets <ilya@theIlya.com>"); | ||
861 | MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver"); | ||
862 | MODULE_LICENSE("GPL"); | ||