aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGiuseppe CAVALLARO <peppe.cavallaro@st.com>2012-06-04 15:22:57 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-06 12:34:56 -0400
commitba27ec66ffeb78cbf9f85e168b32551a9aaf2a34 (patch)
treebc15e2b419088346d9265507c2d3e5b1604a2e7e /drivers
parent3d2377144ca66c98fa220bda5f945590cf5cfdc0 (diff)
stmmac: fix driver Kconfig when built as module
This patches fixes the driver when built as dynamic module. In fact, the platform part cannot be built and the probe fails (thanks to Bob Liu that reported this bug). v2: as D. Miller suggested, it is not necessary to make the pci and the platform code mutually exclusive. Having both could also help, at built time ,to verify that all the code is validated and compiles fine. v3: removed wrong Reviewed-by from the patch Reported-by: Bob Liu <lliubbo@gmail.com> cc: Rayagond Kokatanur <rayagond@vayavyalabs.com> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/Kconfig5
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac.h3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c25
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c29
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c4
5 files changed, 31 insertions, 35 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 036428348faa..0076f770e637 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -13,9 +13,8 @@ config STMMAC_ETH
13if STMMAC_ETH 13if STMMAC_ETH
14 14
15config STMMAC_PLATFORM 15config STMMAC_PLATFORM
16 tristate "STMMAC platform bus support" 16 bool "STMMAC Platform bus support"
17 depends on STMMAC_ETH 17 depends on STMMAC_ETH
18 default y
19 ---help--- 18 ---help---
20 This selects the platform specific bus support for 19 This selects the platform specific bus support for
21 the stmmac device driver. This is the driver used 20 the stmmac device driver. This is the driver used
@@ -26,7 +25,7 @@ config STMMAC_PLATFORM
26 If unsure, say N. 25 If unsure, say N.
27 26
28config STMMAC_PCI 27config STMMAC_PCI
29 tristate "STMMAC support on PCI bus (EXPERIMENTAL)" 28 bool "STMMAC PCI bus support (EXPERIMENTAL)"
30 depends on STMMAC_ETH && PCI && EXPERIMENTAL 29 depends on STMMAC_ETH && PCI && EXPERIMENTAL
31 ---help--- 30 ---help---
32 This is to select the Synopsys DWMAC available on PCI devices, 31 This is to select the Synopsys DWMAC available on PCI devices,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 6b5d060ee9de..6d07ba2c8661 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -95,7 +95,8 @@ extern int stmmac_mdio_register(struct net_device *ndev);
95extern void stmmac_set_ethtool_ops(struct net_device *netdev); 95extern void stmmac_set_ethtool_ops(struct net_device *netdev);
96extern const struct stmmac_desc_ops enh_desc_ops; 96extern const struct stmmac_desc_ops enh_desc_ops;
97extern const struct stmmac_desc_ops ndesc_ops; 97extern const struct stmmac_desc_ops ndesc_ops;
98 98extern struct pci_driver stmmac_pci_driver;
99extern struct platform_driver stmmac_pltfr_driver;
99int stmmac_freeze(struct net_device *ndev); 100int stmmac_freeze(struct net_device *ndev);
100int stmmac_restore(struct net_device *ndev); 101int stmmac_restore(struct net_device *ndev);
101int stmmac_resume(struct net_device *ndev); 102int stmmac_resume(struct net_device *ndev);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index ea33eae22eeb..363856951412 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -42,6 +42,7 @@
42#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/prefetch.h> 44#include <linux/prefetch.h>
45#include <linux/pci.h>
45#ifdef CONFIG_STMMAC_DEBUG_FS 46#ifdef CONFIG_STMMAC_DEBUG_FS
46#include <linux/debugfs.h> 47#include <linux/debugfs.h>
47#include <linux/seq_file.h> 48#include <linux/seq_file.h>
@@ -2093,6 +2094,30 @@ int stmmac_restore(struct net_device *ndev)
2093} 2094}
2094#endif /* CONFIG_PM */ 2095#endif /* CONFIG_PM */
2095 2096
2097static int __init stmmac_init(void)
2098{
2099 int err = 0;
2100
2101 err = platform_driver_register(&stmmac_pltfr_driver);
2102
2103 if (!err) {
2104 err = pci_register_driver(&stmmac_pci_driver);
2105 if (err)
2106 platform_driver_unregister(&stmmac_pltfr_driver);
2107 }
2108
2109 return err;
2110}
2111
2112static void __exit stmmac_exit(void)
2113{
2114 pci_unregister_driver(&stmmac_pci_driver);
2115 platform_driver_unregister(&stmmac_pltfr_driver);
2116}
2117
2118module_init(stmmac_init);
2119module_exit(stmmac_exit);
2120
2096#ifndef MODULE 2121#ifndef MODULE
2097static int __init stmmac_cmdline_opt(char *str) 2122static int __init stmmac_cmdline_opt(char *str)
2098{ 2123{
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 58fab5303e9c..cf826e6b6aa1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -179,7 +179,7 @@ static DEFINE_PCI_DEVICE_TABLE(stmmac_id_table) = {
179 179
180MODULE_DEVICE_TABLE(pci, stmmac_id_table); 180MODULE_DEVICE_TABLE(pci, stmmac_id_table);
181 181
182static struct pci_driver stmmac_driver = { 182struct pci_driver stmmac_pci_driver = {
183 .name = STMMAC_RESOURCE_NAME, 183 .name = STMMAC_RESOURCE_NAME,
184 .id_table = stmmac_id_table, 184 .id_table = stmmac_id_table,
185 .probe = stmmac_pci_probe, 185 .probe = stmmac_pci_probe,
@@ -190,33 +190,6 @@ static struct pci_driver stmmac_driver = {
190#endif 190#endif
191}; 191};
192 192
193/**
194 * stmmac_init_module - Entry point for the driver
195 * Description: This function is the entry point for the driver.
196 */
197static int __init stmmac_init_module(void)
198{
199 int ret;
200
201 ret = pci_register_driver(&stmmac_driver);
202 if (ret < 0)
203 pr_err("%s: ERROR: driver registration failed\n", __func__);
204
205 return ret;
206}
207
208/**
209 * stmmac_cleanup_module - Cleanup routine for the driver
210 * Description: This function is the cleanup routine for the driver.
211 */
212static void __exit stmmac_cleanup_module(void)
213{
214 pci_unregister_driver(&stmmac_driver);
215}
216
217module_init(stmmac_init_module);
218module_exit(stmmac_cleanup_module);
219
220MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PCI driver"); 193MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PCI driver");
221MODULE_AUTHOR("Rayagond Kokatanur <rayagond.kokatanur@vayavyalabs.com>"); 194MODULE_AUTHOR("Rayagond Kokatanur <rayagond.kokatanur@vayavyalabs.com>");
222MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); 195MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 3dd8f0803808..680d2b8dfe27 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -255,7 +255,7 @@ static const struct of_device_id stmmac_dt_ids[] = {
255}; 255};
256MODULE_DEVICE_TABLE(of, stmmac_dt_ids); 256MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
257 257
258static struct platform_driver stmmac_driver = { 258struct platform_driver stmmac_pltfr_driver = {
259 .probe = stmmac_pltfr_probe, 259 .probe = stmmac_pltfr_probe,
260 .remove = stmmac_pltfr_remove, 260 .remove = stmmac_pltfr_remove,
261 .driver = { 261 .driver = {
@@ -266,8 +266,6 @@ static struct platform_driver stmmac_driver = {
266 }, 266 },
267}; 267};
268 268
269module_platform_driver(stmmac_driver);
270
271MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PLATFORM driver"); 269MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PLATFORM driver");
272MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); 270MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
273MODULE_LICENSE("GPL"); 271MODULE_LICENSE("GPL");