diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2012-07-11 14:20:20 +0300 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-08-01 17:47:26 +0800 |
commit | 8bf6f59f328ba9ec49c4eab6c533857fdaa90b3e (patch) | |
tree | df18307066a595e424882697971dfd77e9817902 /crypto | |
parent | 496f0b1cd650e67c5a99876ee275903b81e39d2b (diff) | |
download | linux-crypto-8bf6f59f328ba9ec49c4eab6c533857fdaa90b3e.tar.gz linux-crypto-8bf6f59f328ba9ec49c4eab6c533857fdaa90b3e.zip |
crypto: add crypto_[un]register_shashes for [un]registering multiple shash entries at once
Add crypto_[un]register_shashes() to allow simplifying init/exit code of shash
crypto modules that register multiple algorithms.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/shash.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/crypto/shash.c b/crypto/shash.c index 32067f47..f426330f 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -629,6 +629,42 @@ int crypto_unregister_shash(struct shash_alg *alg) } EXPORT_SYMBOL_GPL(crypto_unregister_shash); +int crypto_register_shashes(struct shash_alg *algs, int count) +{ + int i, ret; + + for (i = 0; i < count; i++) { + ret = crypto_register_shash(&algs[i]); + if (ret) + goto err; + } + + return 0; + +err: + for (--i; i >= 0; --i) + crypto_unregister_shash(&algs[i]); + + return ret; +} +EXPORT_SYMBOL_GPL(crypto_register_shashes); + +int crypto_unregister_shashes(struct shash_alg *algs, int count) +{ + int i, ret; + + for (i = count - 1; i >= 0; --i) { + ret = crypto_unregister_shash(&algs[i]); + if (ret) + pr_err("Failed to unregister %s %s: %d\n", + algs[i].base.cra_driver_name, + algs[i].base.cra_name, ret); + } + + return 0; +} +EXPORT_SYMBOL_GPL(crypto_unregister_shashes); + int shash_register_instance(struct crypto_template *tmpl, struct shash_instance *inst) { |