crypto: n2 - Use platform_register/unregister_drivers()
authorThierry Reding <treding@nvidia.com>
Wed, 2 Dec 2015 16:16:36 +0000 (17:16 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 4 Dec 2015 14:29:57 +0000 (22:29 +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>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/n2_core.c

index 5450880abb7b97a4f3ba29fb36b384b91e639965..739a786b9f0891817b676114070639d943530cf6 100644 (file)
@@ -2243,22 +2243,19 @@ static struct platform_driver n2_mau_driver = {
        .remove         =       n2_mau_remove,
 };
 
+static struct platform_driver * const drivers[] = {
+       &n2_crypto_driver,
+       &n2_mau_driver,
+};
+
 static int __init n2_init(void)
 {
-       int err = platform_driver_register(&n2_crypto_driver);
-
-       if (!err) {
-               err = platform_driver_register(&n2_mau_driver);
-               if (err)
-                       platform_driver_unregister(&n2_crypto_driver);
-       }
-       return err;
+       return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 static void __exit n2_exit(void)
 {
-       platform_driver_unregister(&n2_mau_driver);
-       platform_driver_unregister(&n2_crypto_driver);
+       platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 module_init(n2_init);