net: bfin_mac: Use platform_register/unregister_drivers()
authorThierry Reding <treding@nvidia.com>
Wed, 2 Dec 2015 16:30:26 +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/adi/bfin_mac.c

index 096531a7312495006abdc4b81dc03d7df6def169..e0e95a15cab08bd973bddb7e1d6134ccf9163372 100644 (file)
@@ -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);