leds: sunfire: Use platform_register/unregister_drivers()
authorThierry Reding <treding@nvidia.com>
Wed, 2 Dec 2015 16:27:01 +0000 (17:27 +0100)
committerJacek Anaszewski <j.anaszewski@samsung.com>
Mon, 4 Jan 2016 08:57:38 +0000 (09:57 +0100)
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: Jacek Anaszewski <j.anaszewski@samsung.com>
drivers/leds/leds-sunfire.c

index c2553c54f2cf4794145c29b3e5ee83b365c1a494..7c09db8bd4e8724a9a8b86bc07050c0c73cbfe31 100644 (file)
@@ -234,28 +234,19 @@ static struct platform_driver sunfire_fhc_led_driver = {
        },
 };
 
+static struct platform_driver * const drivers[] = {
+       &sunfire_clockboard_led_driver,
+       &sunfire_fhc_led_driver,
+};
+
 static int __init sunfire_leds_init(void)
 {
-       int err = platform_driver_register(&sunfire_clockboard_led_driver);
-
-       if (err) {
-               pr_err("Could not register clock board LED driver\n");
-               return err;
-       }
-
-       err = platform_driver_register(&sunfire_fhc_led_driver);
-       if (err) {
-               pr_err("Could not register FHC LED driver\n");
-               platform_driver_unregister(&sunfire_clockboard_led_driver);
-       }
-
-       return err;
+       return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 static void __exit sunfire_leds_exit(void)
 {
-       platform_driver_unregister(&sunfire_clockboard_led_driver);
-       platform_driver_unregister(&sunfire_fhc_led_driver);
+       platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 module_init(sunfire_leds_init);