crypto: n2 - Use platform_register/unregister_drivers()

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>
This commit is contained in:
Thierry Reding 2015-12-02 17:16:36 +01:00 committed by Herbert Xu
parent 5e75ae1b3c
commit a103a75ad9
1 changed files with 7 additions and 10 deletions

View File

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