net: mv643xx: Use platform_register/unregister_drivers()
authorThierry Reding <treding@nvidia.com>
Wed, 2 Dec 2015 16:30:29 +0000 (17:30 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Dec 2015 20:14:58 +0000 (15:14 -0500)
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 <treding@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/mv643xx_eth.c

index 4182290fdbcf109aadf6a0f25154b71757d3d25c..4eba2ed530525e24970246936fe9972151a0d97a 100644 (file)
@@ -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);