aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorKonstantin Khlebnikov <khlebnikov@openvz.org>2012-12-13 20:02:51 -0500
committerDavid S. Miller <davem@davemloft.net>2012-12-14 13:14:07 -0500
commit493682b8b8a9bf130a544d983c63f1b35df688b9 (patch)
treefab5919bd4a53bd8f341e7fbc71ddc3f2ca5091b /drivers/net/ethernet
parent4a0ae7b0a9e55db9b85f8abda623f145311eb951 (diff)
stmmac: fix platform driver unregistering
This patch fixes platform device drivers unregistering and adds proper error handing on module loading. Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org> Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com> Cc: netdev@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac.h6
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c22
2 files changed, 15 insertions, 13 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 023a4fb4efa..b05df8983be 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -127,14 +127,14 @@ static inline int stmmac_register_platform(void)
127} 127}
128static inline void stmmac_unregister_platform(void) 128static inline void stmmac_unregister_platform(void)
129{ 129{
130 platform_driver_register(&stmmac_pltfr_driver); 130 platform_driver_unregister(&stmmac_pltfr_driver);
131} 131}
132#else 132#else
133static inline int stmmac_register_platform(void) 133static inline int stmmac_register_platform(void)
134{ 134{
135 pr_debug("stmmac: do not register the platf driver\n"); 135 pr_debug("stmmac: do not register the platf driver\n");
136 136
137 return -EINVAL; 137 return 0;
138} 138}
139static inline void stmmac_unregister_platform(void) 139static inline void stmmac_unregister_platform(void)
140{ 140{
@@ -162,7 +162,7 @@ static inline int stmmac_register_pci(void)
162{ 162{
163 pr_debug("stmmac: do not register the PCI driver\n"); 163 pr_debug("stmmac: do not register the PCI driver\n");
164 164
165 return -EINVAL; 165 return 0;
166} 166}
167static inline void stmmac_unregister_pci(void) 167static inline void stmmac_unregister_pci(void)
168{ 168{
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 542edbcd92c..f07c0612abf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2194,18 +2194,20 @@ int stmmac_restore(struct net_device *ndev)
2194 */ 2194 */
2195static int __init stmmac_init(void) 2195static int __init stmmac_init(void)
2196{ 2196{
2197 int err_plt = 0; 2197 int ret;
2198 int err_pci = 0;
2199
2200 err_plt = stmmac_register_platform();
2201 err_pci = stmmac_register_pci();
2202
2203 if ((err_pci) && (err_plt)) {
2204 pr_err("stmmac: driver registration failed\n");
2205 return -EINVAL;
2206 }
2207 2198
2199 ret = stmmac_register_platform();
2200 if (ret)
2201 goto err;
2202 ret = stmmac_register_pci();
2203 if (ret)
2204 goto err_pci;
2208 return 0; 2205 return 0;
2206err_pci:
2207 stmmac_unregister_platform();
2208err:
2209 pr_err("stmmac: driver registration failed\n");
2210 return ret;
2209} 2211}
2210 2212
2211static void __exit stmmac_exit(void) 2213static void __exit stmmac_exit(void)