Skip to contentSkip to conversation

net: bfin_mac: Use platform_register/unregister_drivers()

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

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

PATCH 1/4 net: bfin_mac: 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.

---
Applies on top of next-20151127.

 drivers/net/ethernet/adi/bfin_mac.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/adi/bfin_mac.c +7 -7
index 096531a73124..e0e95a15cab0 100644
@@ -1912,21 +1912,21 @@ static struct platform_driver bfin_mac_driver = {
 	},
 };
 
+static struct platform_driver * const drivers[] = {
+	&bfin_mii_bus_driver,
+	&bfin_mac_driver,
+};
+
 static int __init bfin_mac_init(void)
 {
-	int ret;
-	ret = platform_driver_register(&bfin_mii_bus_driver);
-	if (!ret)
-		return platform_driver_register(&bfin_mac_driver);
-	return -ENODEV;
+	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 module_init(bfin_mac_init);
 
 static void __exit bfin_mac_cleanup(void)
 {
-	platform_driver_unregister(&bfin_mac_driver);
-	platform_driver_unregister(&bfin_mii_bus_driver);
+	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 module_exit(bfin_mac_cleanup);
Signature · 1 line
2.5.0
#1 lore raw

PATCH 2/4 net: bcm63xx: 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.

---
Applies on top of next-20151127.

 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)
drivers/net/ethernet/broadcom/bcm63xx_enet.c +8 -20
index 8b1929e9f698..a54bafad3538 100644
@@ -2884,33 +2884,21 @@ struct platform_driver bcm63xx_enet_shared_driver = {
 	},
 };
 
+static struct platform_driver * const drivers[] = {
+	&bcm63xx_enet_shared_driver,
+	&bcm63xx_enet_driver,
+	&bcm63xx_enetsw_driver,
+};
+
 /* entry point */
 static int __init bcm_enet_init(void)
 {
-	int ret;
-
-	ret = platform_driver_register(&bcm63xx_enet_shared_driver);
-	if (ret)
-		return ret;
-
-	ret = platform_driver_register(&bcm63xx_enet_driver);
-	if (ret)
-		platform_driver_unregister(&bcm63xx_enet_shared_driver);
-
-	ret = platform_driver_register(&bcm63xx_enetsw_driver);
-	if (ret) {
-		platform_driver_unregister(&bcm63xx_enet_driver);
-		platform_driver_unregister(&bcm63xx_enet_shared_driver);
-	}
-
-	return ret;
+	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 static void __exit bcm_enet_exit(void)
 {
-	platform_driver_unregister(&bcm63xx_enet_driver);
-	platform_driver_unregister(&bcm63xx_enetsw_driver);
-	platform_driver_unregister(&bcm63xx_enet_shared_driver);
+	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 
Signature · 1 line
2.5.0
maintainer Applied
#2 lore raw

Re: [PATCH 2/4] net: bcm63xx: Use platform_register/unregister_drivers()

From: Thierry Reding <[email protected]>
Date: Wed, 2 Dec 2015 17:30:27 +0100

Quoted 7 lines

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.

#3 lore raw

PATCH 3/4 net: mpc52xx: Use platform_register/unregister_drivers()

In reply to 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.

---
Applies on top of next-20151127.

 drivers/net/ethernet/freescale/fec_mpc52xx.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/net/ethernet/freescale/fec_mpc52xx.c +9 -13
index afe7f39cdd7c..25553ee857b4 100644
@@ -1084,27 +1084,23 @@ static struct platform_driver mpc52xx_fec_driver = {
 /* Module                                                                   */
 /* ======================================================================== */
 
+static struct platform_driver * const drivers[] = {
+#ifdef CONFIG_FEC_MPC52xx_MDIO
+	&mpc52xx_fec_mdio_driver,
+#endif
+	&mpc52xx_fec_driver,
+};
+
 static int __init
 mpc52xx_fec_init(void)
 {
-#ifdef CONFIG_FEC_MPC52xx_MDIO
-	int ret;
-	ret = platform_driver_register(&mpc52xx_fec_mdio_driver);
-	if (ret) {
-		pr_err("failed to register mdio driver\n");
-		return ret;
-	}
-#endif
-	return platform_driver_register(&mpc52xx_fec_driver);
+	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 static void __exit
 mpc52xx_fec_exit(void)
 {
-	platform_driver_unregister(&mpc52xx_fec_driver);
-#ifdef CONFIG_FEC_MPC52xx_MDIO
-	platform_driver_unregister(&mpc52xx_fec_mdio_driver);
-#endif
+	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 
Signature · 1 line
2.5.0
maintainer Applied
#4 lore raw

Re: [PATCH 3/4] net: mpc52xx: Use platform_register/unregister_drivers()

From: Thierry Reding <[email protected]>
Date: Wed, 2 Dec 2015 17:30:28 +0100

Quoted 7 lines

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.

#5 lore raw

PATCH 4/4 net: mv643xx: Use platform_register/unregister_drivers()

In reply to 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.

---
Applies on top of next-20151127.

 drivers/net/ethernet/marvell/mv643xx_eth.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +7 -12
index 4182290fdbcf..4eba2ed53052 100644
@@ -3257,25 +3257,20 @@ static struct platform_driver mv643xx_eth_driver = {
 	},
 };
 
+static struct platform_driver * const drivers[] = {
+	&mv643xx_eth_shared_driver,
+	&mv643xx_eth_driver,
+};
+
 static int __init mv643xx_eth_init_module(void)
 {
-	int rc;
-
-	rc = platform_driver_register(&mv643xx_eth_shared_driver);
-	if (!rc) {
-		rc = platform_driver_register(&mv643xx_eth_driver);
-		if (rc)
-			platform_driver_unregister(&mv643xx_eth_shared_driver);
-	}
-
-	return rc;
+	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 module_init(mv643xx_eth_init_module);
 
 static void __exit mv643xx_eth_cleanup_module(void)
 {
-	platform_driver_unregister(&mv643xx_eth_driver);
-	platform_driver_unregister(&mv643xx_eth_shared_driver);
+	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 module_exit(mv643xx_eth_cleanup_module);
 
Signature · 1 line
2.5.0
maintainer Applied
#6 lore raw

Re: [PATCH 4/4] net: mv643xx: Use platform_register/unregister_drivers()

From: Thierry Reding <[email protected]>
Date: Wed, 2 Dec 2015 17:30:29 +0100

Quoted 7 lines

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.