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

index fd342dffe4dc766cefe93a29b3408476753b7316..8e9e8eab59ba75c6c7643b41453d81d62e1d7187 100644 (file)
@@ -1102,32 +1102,24 @@ static struct platform_driver adi_gpio_driver = {
        },
 };
 
+static struct platform_driver * const drivers[] = {
+       &adi_pinctrl_driver,
+       &adi_gpio_pint_driver,
+       &adi_gpio_driver,
+};
+
 static int __init adi_pinctrl_setup(void)
 {
        int ret;
 
-       ret = platform_driver_register(&adi_pinctrl_driver);
+       ret = platform_register_drivers(drivers, ARRAY_SIZE(drivers));
        if (ret)
                return ret;
 
-       ret = platform_driver_register(&adi_gpio_pint_driver);
-       if (ret)
-               goto pint_error;
-
-       ret = platform_driver_register(&adi_gpio_driver);
-       if (ret)
-               goto gpio_error;
-
 #ifdef CONFIG_PM
        register_syscore_ops(&gpio_pm_syscore_ops);
 #endif
-       return ret;
-gpio_error:
-       platform_driver_unregister(&adi_gpio_pint_driver);
-pint_error:
-       platform_driver_unregister(&adi_pinctrl_driver);
-
-       return ret;
+       return 0;
 }
 arch_initcall(adi_pinctrl_setup);