Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jussi Kivilinna and committed by
Herbert Xu
50fc3e8d 8fc229a5

+38
+36
crypto/shash.c
··· 629 629 } 630 630 EXPORT_SYMBOL_GPL(crypto_unregister_shash); 631 631 632 + int 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 + 644 + err: 645 + for (--i; i >= 0; --i) 646 + crypto_unregister_shash(&algs[i]); 647 + 648 + return ret; 649 + } 650 + EXPORT_SYMBOL_GPL(crypto_register_shashes); 651 + 652 + int 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 + } 666 + EXPORT_SYMBOL_GPL(crypto_unregister_shashes); 667 + 632 668 int shash_register_instance(struct crypto_template *tmpl, 633 669 struct shash_instance *inst) 634 670 {
+2
include/crypto/internal/hash.h
··· 83 83 84 84 int crypto_register_shash(struct shash_alg *alg); 85 85 int crypto_unregister_shash(struct shash_alg *alg); 86 + int crypto_register_shashes(struct shash_alg *algs, int count); 87 + int crypto_unregister_shashes(struct shash_alg *algs, int count); 86 88 int shash_register_instance(struct crypto_template *tmpl, 87 89 struct shash_instance *inst); 88 90 void shash_free_instance(struct crypto_instance *inst);