aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@mbnet.fi>2012-07-11 07:20:20 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2012-08-01 05:47:26 -0400
commit50fc3e8d2c9d1ee72c67b751e5ac5d76ebc5a12e (patch)
tree29be3f3cff2b30a5c1d6ece2cc6a200668a7003f /crypto
parent8fc229a51b0e10f4ceb794e8b99fa0a427a7ba41 (diff)
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.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/crypto/shash.c b/crypto/shash.c
index 32067f47e6c7..f426330f1017 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -629,6 +629,42 @@ int crypto_unregister_shash(struct shash_alg *alg)
629} 629}
630EXPORT_SYMBOL_GPL(crypto_unregister_shash); 630EXPORT_SYMBOL_GPL(crypto_unregister_shash);
631 631
632int crypto_register_shashes(struct shash_alg *algs, int count)
633{
634 int i, ret;
635
636 for (i = 0; i < count; i++) {
637 ret = crypto_register_shash(&algs[i]);
638 if (ret)
639 goto err;
640 }
641
642 return 0;
643
644err:
645 for (--i; i >= 0; --i)
646 crypto_unregister_shash(&algs[i]);
647
648 return ret;
649}
650EXPORT_SYMBOL_GPL(crypto_register_shashes);
651
652int crypto_unregister_shashes(struct shash_alg *algs, int count)
653{
654 int i, ret;
655
656 for (i = count - 1; i >= 0; --i) {
657 ret = crypto_unregister_shash(&algs[i]);
658 if (ret)
659 pr_err("Failed to unregister %s %s: %d\n",
660 algs[i].base.cra_driver_name,
661 algs[i].base.cra_name, ret);
662 }
663
664 return 0;
665}
666EXPORT_SYMBOL_GPL(crypto_unregister_shashes);
667
632int shash_register_instance(struct crypto_template *tmpl, 668int shash_register_instance(struct crypto_template *tmpl,
633 struct shash_instance *inst) 669 struct shash_instance *inst)
634{ 670{