diff options
author | Alan Cox <alan@linux.intel.com> | 2009-08-27 06:03:21 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 15:02:29 -0400 |
commit | 7ca5d4229093bedef3a89772249f8a2f74421a1a (patch) | |
tree | 6d9e8a8e9e1c833398b8b90bcbbcb7d1db303bdc | |
parent | 15700039b108fccc36507bcabdd4dda93f7c4c61 (diff) |
Staging: et131x: re-order the initpci code to match usual Linux style
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/et131x/et131x_initpci.c | 177 |
1 files changed, 84 insertions, 93 deletions
diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 2d8b62f066a8..9db205667262 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c | |||
@@ -102,16 +102,6 @@ | |||
102 | #include "et1310_eeprom.h" | 102 | #include "et1310_eeprom.h" |
103 | 103 | ||
104 | 104 | ||
105 | int __devinit et131x_pci_setup(struct pci_dev *pdev, | ||
106 | const struct pci_device_id *ent); | ||
107 | void __devexit et131x_pci_remove(struct pci_dev *pdev); | ||
108 | |||
109 | |||
110 | /* Modinfo parameters (filled out using defines from et131x_version.h) */ | ||
111 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
112 | MODULE_DESCRIPTION(DRIVER_INFO); | ||
113 | MODULE_LICENSE(DRIVER_LICENSE); | ||
114 | |||
115 | /* Defines for Parameter Default/Min/Max vaules */ | 105 | /* Defines for Parameter Default/Min/Max vaules */ |
116 | #define PARM_SPEED_DUPLEX_MIN 0 | 106 | #define PARM_SPEED_DUPLEX_MIN 0 |
117 | #define PARM_SPEED_DUPLEX_MAX 5 | 107 | #define PARM_SPEED_DUPLEX_MAX 5 |
@@ -141,60 +131,6 @@ module_param(et131x_speed_set, uint, 0); | |||
141 | MODULE_PARM_DESC(et131x_speed_set, | 131 | MODULE_PARM_DESC(et131x_speed_set, |
142 | "Set Link speed and dublex manually (0-5) [0] \n 1 : 10Mb Half-Duplex \n 2 : 10Mb Full-Duplex \n 3 : 100Mb Half-Duplex \n 4 : 100Mb Full-Duplex \n 5 : 1000Mb Full-Duplex \n 0 : Auto Speed Auto Dublex"); | 132 | "Set Link speed and dublex manually (0-5) [0] \n 1 : 10Mb Half-Duplex \n 2 : 10Mb Full-Duplex \n 3 : 100Mb Half-Duplex \n 4 : 100Mb Full-Duplex \n 5 : 1000Mb Full-Duplex \n 0 : Auto Speed Auto Dublex"); |
143 | 133 | ||
144 | |||
145 | |||
146 | static struct pci_device_id et131x_pci_table[] __devinitdata = { | ||
147 | {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID, | ||
148 | PCI_ANY_ID, 0, 0, 0UL}, | ||
149 | {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_FAST, PCI_ANY_ID, | ||
150 | PCI_ANY_ID, 0, 0, 0UL}, | ||
151 | {0,} | ||
152 | }; | ||
153 | |||
154 | MODULE_DEVICE_TABLE(pci, et131x_pci_table); | ||
155 | |||
156 | static struct pci_driver et131x_driver = { | ||
157 | .name = DRIVER_NAME, | ||
158 | .id_table = et131x_pci_table, | ||
159 | .probe = et131x_pci_setup, | ||
160 | .remove = __devexit_p(et131x_pci_remove), | ||
161 | .suspend = NULL, /* et131x_pci_suspend */ | ||
162 | .resume = NULL, /* et131x_pci_resume */ | ||
163 | }; | ||
164 | |||
165 | |||
166 | /** | ||
167 | * et131x_init_module - The "main" entry point called on driver initialization | ||
168 | * | ||
169 | * Returns 0 on success, errno on failure (as defined in errno.h) | ||
170 | */ | ||
171 | static int et131x_init_module(void) | ||
172 | { | ||
173 | if (et131x_speed_set < PARM_SPEED_DUPLEX_MIN || | ||
174 | et131x_speed_set > PARM_SPEED_DUPLEX_MAX) { | ||
175 | printk(KERN_WARNING "et131x: invalid speed setting ignored.\n"); | ||
176 | et131x_speed_set = 0; | ||
177 | } | ||
178 | return pci_register_driver(&et131x_driver); | ||
179 | } | ||
180 | |||
181 | /** | ||
182 | * et131x_cleanup_module - The entry point called on driver cleanup | ||
183 | */ | ||
184 | static void et131x_cleanup_module(void) | ||
185 | { | ||
186 | pci_unregister_driver(&et131x_driver); | ||
187 | } | ||
188 | |||
189 | /* | ||
190 | * These macros map the driver-specific init_module() and cleanup_module() | ||
191 | * routines so they can be called by the kernel. | ||
192 | */ | ||
193 | |||
194 | module_init(et131x_init_module); | ||
195 | module_exit(et131x_cleanup_module); | ||
196 | |||
197 | |||
198 | /** | 134 | /** |
199 | * et131x_find_adapter - Find the adapter and get all the assigned resources | 135 | * et131x_find_adapter - Find the adapter and get all the assigned resources |
200 | * @adapter: pointer to our private adapter structure | 136 | * @adapter: pointer to our private adapter structure |
@@ -697,35 +633,6 @@ void et131x_adapter_memory_free(struct et131x_adapter *adapter) | |||
697 | } | 633 | } |
698 | 634 | ||
699 | /** | 635 | /** |
700 | * et131x_pci_remove | ||
701 | * @pdev: a pointer to the device's pci_dev structure | ||
702 | * | ||
703 | * Registered in the pci_driver structure, this function is called when the | ||
704 | * PCI subsystem detects that a PCI device which matches the information | ||
705 | * contained in the pci_device_id table has been removed. | ||
706 | */ | ||
707 | void __devexit et131x_pci_remove(struct pci_dev *pdev) | ||
708 | { | ||
709 | struct net_device *netdev; | ||
710 | struct et131x_adapter *adapter; | ||
711 | |||
712 | /* Retrieve the net_device pointer from the pci_dev struct, as well | ||
713 | * as the private adapter struct | ||
714 | */ | ||
715 | netdev = (struct net_device *) pci_get_drvdata(pdev); | ||
716 | adapter = netdev_priv(netdev); | ||
717 | |||
718 | /* Perform device cleanup */ | ||
719 | unregister_netdev(netdev); | ||
720 | et131x_adapter_memory_free(adapter); | ||
721 | iounmap(adapter->regs); | ||
722 | pci_dev_put(adapter->pdev); | ||
723 | free_netdev(netdev); | ||
724 | pci_release_regions(pdev); | ||
725 | pci_disable_device(pdev); | ||
726 | } | ||
727 | |||
728 | /** | ||
729 | * et131x_config_parse | 636 | * et131x_config_parse |
730 | * @etdev: pointer to the private adapter struct | 637 | * @etdev: pointer to the private adapter struct |
731 | * | 638 | * |
@@ -771,6 +678,37 @@ void et131x_config_parse(struct et131x_adapter *etdev) | |||
771 | 678 | ||
772 | 679 | ||
773 | /** | 680 | /** |
681 | * et131x_pci_remove | ||
682 | * @pdev: a pointer to the device's pci_dev structure | ||
683 | * | ||
684 | * Registered in the pci_driver structure, this function is called when the | ||
685 | * PCI subsystem detects that a PCI device which matches the information | ||
686 | * contained in the pci_device_id table has been removed. | ||
687 | */ | ||
688 | |||
689 | void __devexit et131x_pci_remove(struct pci_dev *pdev) | ||
690 | { | ||
691 | struct net_device *netdev; | ||
692 | struct et131x_adapter *adapter; | ||
693 | |||
694 | /* Retrieve the net_device pointer from the pci_dev struct, as well | ||
695 | * as the private adapter struct | ||
696 | */ | ||
697 | netdev = (struct net_device *) pci_get_drvdata(pdev); | ||
698 | adapter = netdev_priv(netdev); | ||
699 | |||
700 | /* Perform device cleanup */ | ||
701 | unregister_netdev(netdev); | ||
702 | et131x_adapter_memory_free(adapter); | ||
703 | iounmap(adapter->regs); | ||
704 | pci_dev_put(adapter->pdev); | ||
705 | free_netdev(netdev); | ||
706 | pci_release_regions(pdev); | ||
707 | pci_disable_device(pdev); | ||
708 | } | ||
709 | |||
710 | |||
711 | /** | ||
774 | * et131x_pci_setup - Perform device initialization | 712 | * et131x_pci_setup - Perform device initialization |
775 | * @pdev: a pointer to the device's pci_dev structure | 713 | * @pdev: a pointer to the device's pci_dev structure |
776 | * @ent: this device's entry in the pci_device_id table | 714 | * @ent: this device's entry in the pci_device_id table |
@@ -782,6 +720,7 @@ void et131x_config_parse(struct et131x_adapter *etdev) | |||
782 | * contained in the pci_device_id table. This routine is the equivalent to | 720 | * contained in the pci_device_id table. This routine is the equivalent to |
783 | * a device insertion routine. | 721 | * a device insertion routine. |
784 | */ | 722 | */ |
723 | |||
785 | int __devinit et131x_pci_setup(struct pci_dev *pdev, | 724 | int __devinit et131x_pci_setup(struct pci_dev *pdev, |
786 | const struct pci_device_id *ent) | 725 | const struct pci_device_id *ent) |
787 | { | 726 | { |
@@ -1024,3 +963,55 @@ err_disable: | |||
1024 | pci_disable_device(pdev); | 963 | pci_disable_device(pdev); |
1025 | goto out; | 964 | goto out; |
1026 | } | 965 | } |
966 | |||
967 | static struct pci_device_id et131x_pci_table[] __devinitdata = { | ||
968 | {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID, | ||
969 | PCI_ANY_ID, 0, 0, 0UL}, | ||
970 | {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_FAST, PCI_ANY_ID, | ||
971 | PCI_ANY_ID, 0, 0, 0UL}, | ||
972 | {0,} | ||
973 | }; | ||
974 | |||
975 | MODULE_DEVICE_TABLE(pci, et131x_pci_table); | ||
976 | |||
977 | static struct pci_driver et131x_driver = { | ||
978 | .name = DRIVER_NAME, | ||
979 | .id_table = et131x_pci_table, | ||
980 | .probe = et131x_pci_setup, | ||
981 | .remove = __devexit_p(et131x_pci_remove), | ||
982 | .suspend = NULL, /* et131x_pci_suspend */ | ||
983 | .resume = NULL, /* et131x_pci_resume */ | ||
984 | }; | ||
985 | |||
986 | |||
987 | /** | ||
988 | * et131x_init_module - The "main" entry point called on driver initialization | ||
989 | * | ||
990 | * Returns 0 on success, errno on failure (as defined in errno.h) | ||
991 | */ | ||
992 | static int et131x_init_module(void) | ||
993 | { | ||
994 | if (et131x_speed_set < PARM_SPEED_DUPLEX_MIN || | ||
995 | et131x_speed_set > PARM_SPEED_DUPLEX_MAX) { | ||
996 | printk(KERN_WARNING "et131x: invalid speed setting ignored.\n"); | ||
997 | et131x_speed_set = 0; | ||
998 | } | ||
999 | return pci_register_driver(&et131x_driver); | ||
1000 | } | ||
1001 | |||
1002 | /** | ||
1003 | * et131x_cleanup_module - The entry point called on driver cleanup | ||
1004 | */ | ||
1005 | static void et131x_cleanup_module(void) | ||
1006 | { | ||
1007 | pci_unregister_driver(&et131x_driver); | ||
1008 | } | ||
1009 | |||
1010 | module_init(et131x_init_module); | ||
1011 | module_exit(et131x_cleanup_module); | ||
1012 | |||
1013 | |||
1014 | /* Modinfo parameters (filled out using defines from et131x_version.h) */ | ||
1015 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
1016 | MODULE_DESCRIPTION(DRIVER_INFO); | ||
1017 | MODULE_LICENSE(DRIVER_LICENSE); | ||