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>
This commit is contained in:
parent
4a0ae7b0a9
commit
493682b8b8
|
@ -127,14 +127,14 @@ static inline int stmmac_register_platform(void)
|
|||
}
|
||||
static inline void stmmac_unregister_platform(void)
|
||||
{
|
||||
platform_driver_register(&stmmac_pltfr_driver);
|
||||
platform_driver_unregister(&stmmac_pltfr_driver);
|
||||
}
|
||||
#else
|
||||
static inline int stmmac_register_platform(void)
|
||||
{
|
||||
pr_debug("stmmac: do not register the platf driver\n");
|
||||
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
static inline void stmmac_unregister_platform(void)
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ static inline int stmmac_register_pci(void)
|
|||
{
|
||||
pr_debug("stmmac: do not register the PCI driver\n");
|
||||
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
static inline void stmmac_unregister_pci(void)
|
||||
{
|
||||
|
|
|
@ -2194,18 +2194,20 @@ int stmmac_restore(struct net_device *ndev)
|
|||
*/
|
||||
static int __init stmmac_init(void)
|
||||
{
|
||||
int err_plt = 0;
|
||||
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;
|
||||
}
|
||||
int ret;
|
||||
|
||||
ret = stmmac_register_platform();
|
||||
if (ret)
|
||||
goto err;
|
||||
ret = stmmac_register_pci();
|
||||
if (ret)
|
||||
goto err_pci;
|
||||
return 0;
|
||||
err_pci:
|
||||
stmmac_unregister_platform();
|
||||
err:
|
||||
pr_err("stmmac: driver registration failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit stmmac_exit(void)
|
||||
|
|
Loading…
Reference in New Issue