Skip to contentSkip to conversation

edac: mpc85xx: Use platform_register/unregister_drivers()

PATCH Applied Thierry Reding 2 participants 2 messages Dec 3, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 edac: mpc85xx: Use platform_register/unregister_drivers()

From: Thierry Reding <[email protected]>

These new helpers simplify implementing multi-driver modules and properly handle failure to register one driver by unregistering all previously registered drivers.

---
Changes in v2:
- fixup commit subject and add Reviewed-by (Johannes Thumshirn)

Note sure this was clear from the submission, but the patches that add the platform_register/unregister_drivers() functions were merged in v4.4-rc1, so maintainers are free to apply these patches to their trees.

 drivers/edac/mpc85xx_edac.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/edac/mpc85xx_edac.c +8 -8
index 23ef8e9f2c9a..3eab06351089 100644
@@ -1208,6 +1208,11 @@ static void __init mpc85xx_mc_clear_rfxe(void *data)
 }
 #endif
 
+static struct platform_driver * const drivers[] = {
+	&mpc85xx_mc_err_driver,
+	&mpc85xx_l2_err_driver,
+};
+
 static int __init mpc85xx_mc_init(void)
 {
 	int res = 0;
@@ -1226,13 +1231,9 @@ static int __init mpc85xx_mc_init(void)
 		break;
 	}
 
-	res = platform_driver_register(&mpc85xx_mc_err_driver);
-	if (res)
-		printk(KERN_WARNING EDAC_MOD_STR "MC fails to register\n");
-
-	res = platform_driver_register(&mpc85xx_l2_err_driver);
+	res = platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 	if (res)
-		printk(KERN_WARNING EDAC_MOD_STR "L2 fails to register\n");
+		printk(KERN_WARNING EDAC_MOD_STR "drivers fail to register\n");
 
 #ifdef CONFIG_FSL_SOC_BOOKE
 	pvr = mfspr(SPRN_PVR);
@@ -1270,8 +1271,7 @@ static void __exit mpc85xx_mc_exit(void)
 		on_each_cpu(mpc85xx_mc_restore_hid1, NULL, 0);
 	}
 #endif
-	platform_driver_unregister(&mpc85xx_l2_err_driver);
-	platform_driver_unregister(&mpc85xx_mc_err_driver);
+	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 module_exit(mpc85xx_mc_exit);
Signature · 1 line
2.5.0
maintainer Applied
#1 lore raw
Quoted 8 lines · Thierry Reding

From: Thierry Reding <[email protected]>

These new helpers simplify implementing multi-driver modules and properly handle failure to register one driver by unregistering all previously registered drivers.

Applied, thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.