Input: sparcspkr - use platform_register/unregister_drivers()
authorThierry Reding <treding@nvidia.com>
Wed, 2 Dec 2015 17:28:03 +0000 (09:28 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 2 Dec 2015 18:02:50 +0000 (10:02 -0800)
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: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/sparcspkr.c

index 6f997aa49183ae40daa709361e1b66f19fb862a8..4a5afc7fe96ead167bdf1ef918e39b6095c7cfd4 100644 (file)
@@ -345,23 +345,19 @@ static struct platform_driver grover_beep_driver = {
        .shutdown       = sparcspkr_shutdown,
 };
 
+static struct platform_driver * const drivers[] = {
+       &bbc_beep_driver,
+       &grover_beep_driver,
+};
+
 static int __init sparcspkr_init(void)
 {
-       int err = platform_driver_register(&bbc_beep_driver);
-
-       if (!err) {
-               err = platform_driver_register(&grover_beep_driver);
-               if (err)
-                       platform_driver_unregister(&bbc_beep_driver);
-       }
-
-       return err;
+       return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 static void __exit sparcspkr_exit(void)
 {
-       platform_driver_unregister(&bbc_beep_driver);
-       platform_driver_unregister(&grover_beep_driver);
+       platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 module_init(sparcspkr_init);