pinctrl: at91: Use platform_register/unregister_drivers()
authorThierry Reding <treding@nvidia.com>
Wed, 2 Dec 2015 16:31:55 +0000 (17:31 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 10 Dec 2015 22:50:53 +0000 (23:50 +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: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-at91.c

index 0d2fc0cff35ee6216ef5e62a77376e63cb2675e7..47b625b1b789fb0c10c08a940fd0766bcf93358a 100644 (file)
@@ -1828,20 +1828,20 @@ static struct platform_driver at91_pinctrl_driver = {
        .remove = at91_pinctrl_remove,
 };
 
+static struct platform_driver * const drivers[] = {
+       &at91_gpio_driver,
+       &at91_pinctrl_driver,
+};
+
 static int __init at91_pinctrl_init(void)
 {
-       int ret;
-
-       ret = platform_driver_register(&at91_gpio_driver);
-       if (ret)
-               return ret;
-       return platform_driver_register(&at91_pinctrl_driver);
+       return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 arch_initcall(at91_pinctrl_init);
 
 static void __exit at91_pinctrl_exit(void)
 {
-       platform_driver_unregister(&at91_pinctrl_driver);
+       platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 module_exit(at91_pinctrl_exit);