Skip to content

Commit

Permalink
EDAC, mv64x60: Use platform_register/unregister_drivers()
Browse files Browse the repository at this point in the history
These new helpers simplify implementing multi-driver modules and
properly handle failure to register one driver by unregistering all
previously registered drivers.

Signed-off-by: Thierry Reding <[email protected]>
Cc: linux-edac <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Borislav Petkov <[email protected]>
  • Loading branch information
thierryreding authored and suryasaimadhu committed Dec 3, 2015
1 parent d54051f commit 768ce42
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions drivers/edac/mv64x60_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,15 @@ static struct platform_driver mv64x60_mc_err_driver = {
}
};

static struct platform_driver * const drivers[] = {
&mv64x60_mc_err_driver,
&mv64x60_cpu_err_driver,
&mv64x60_sram_err_driver,
#ifdef CONFIG_PCI
&mv64x60_pci_err_driver,
#endif
};

static int __init mv64x60_edac_init(void)
{
int ret = 0;
Expand All @@ -863,39 +872,13 @@ static int __init mv64x60_edac_init(void)
break;
}

ret = platform_driver_register(&mv64x60_mc_err_driver);
if (ret)
printk(KERN_WARNING EDAC_MOD_STR "MC err failed to register\n");

ret = platform_driver_register(&mv64x60_cpu_err_driver);
if (ret)
printk(KERN_WARNING EDAC_MOD_STR
"CPU err failed to register\n");

ret = platform_driver_register(&mv64x60_sram_err_driver);
if (ret)
printk(KERN_WARNING EDAC_MOD_STR
"SRAM err failed to register\n");

#ifdef CONFIG_PCI
ret = platform_driver_register(&mv64x60_pci_err_driver);
if (ret)
printk(KERN_WARNING EDAC_MOD_STR
"PCI err failed to register\n");
#endif

return ret;
return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
}
module_init(mv64x60_edac_init);

static void __exit mv64x60_edac_exit(void)
{
#ifdef CONFIG_PCI
platform_driver_unregister(&mv64x60_pci_err_driver);
#endif
platform_driver_unregister(&mv64x60_sram_err_driver);
platform_driver_unregister(&mv64x60_cpu_err_driver);
platform_driver_unregister(&mv64x60_mc_err_driver);
platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
}
module_exit(mv64x60_edac_exit);

Expand Down

0 comments on commit 768ce42

Please sign in to comment.