Commit 493682b8 authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov Committed by David S. Miller

stmmac: fix platform driver unregistering

This patch fixes platform device drivers unregistering and adds proper error
handing on module loading.
Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4a0ae7b0
...@@ -127,14 +127,14 @@ static inline int stmmac_register_platform(void) ...@@ -127,14 +127,14 @@ static inline int stmmac_register_platform(void)
} }
static inline void stmmac_unregister_platform(void) static inline void stmmac_unregister_platform(void)
{ {
platform_driver_register(&stmmac_pltfr_driver); platform_driver_unregister(&stmmac_pltfr_driver);
} }
#else #else
static inline int stmmac_register_platform(void) static inline int stmmac_register_platform(void)
{ {
pr_debug("stmmac: do not register the platf driver\n"); pr_debug("stmmac: do not register the platf driver\n");
return -EINVAL; return 0;
} }
static inline void stmmac_unregister_platform(void) static inline void stmmac_unregister_platform(void)
{ {
...@@ -162,7 +162,7 @@ static inline int stmmac_register_pci(void) ...@@ -162,7 +162,7 @@ static inline int stmmac_register_pci(void)
{ {
pr_debug("stmmac: do not register the PCI driver\n"); pr_debug("stmmac: do not register the PCI driver\n");
return -EINVAL; return 0;
} }
static inline void stmmac_unregister_pci(void) static inline void stmmac_unregister_pci(void)
{ {
......
...@@ -2194,18 +2194,20 @@ int stmmac_restore(struct net_device *ndev) ...@@ -2194,18 +2194,20 @@ int stmmac_restore(struct net_device *ndev)
*/ */
static int __init stmmac_init(void) static int __init stmmac_init(void)
{ {
int err_plt = 0; int ret;
int err_pci = 0;
err_plt = stmmac_register_platform();
err_pci = stmmac_register_pci();
if ((err_pci) && (err_plt)) {
pr_err("stmmac: driver registration failed\n");
return -EINVAL;
}
ret = stmmac_register_platform();
if (ret)
goto err;
ret = stmmac_register_pci();
if (ret)
goto err_pci;
return 0; return 0;
err_pci:
stmmac_unregister_platform();
err:
pr_err("stmmac: driver registration failed\n");
return ret;
} }
static void __exit stmmac_exit(void) static void __exit stmmac_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment