summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorXiongfeng Wang <xiongfeng.wang@linaro.org>2019-01-18 08:58:11 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2019-01-25 13:41:52 +0300
commit9572442dcf487e534e70b30f43e21a364cf483e9 (patch)
tree3c6e83ea5ee77e8fe7eefcd134774bce6dce4766 /crypto
parent747bd2a36c9c9a0edd5f393664d962205b31f404 (diff)
downloadlinux-9572442dcf487e534e70b30f43e21a364cf483e9.tar.xz
crypto: api - add a helper to (un)register a array of templates
This patch add a helper to (un)register a array of templates. The following patches will use this helper to simplify the code. Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org> Reviewed-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/algapi.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c
index 713baabeb643..4c9c86b55738 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -494,6 +494,24 @@ out:
}
EXPORT_SYMBOL_GPL(crypto_register_template);
+int crypto_register_templates(struct crypto_template *tmpls, int count)
+{
+ int i, err;
+
+ for (i = 0; i < count; i++) {
+ err = crypto_register_template(&tmpls[i]);
+ if (err)
+ goto out;
+ }
+ return 0;
+
+out:
+ for (--i; i >= 0; --i)
+ crypto_unregister_template(&tmpls[i]);
+ return err;
+}
+EXPORT_SYMBOL_GPL(crypto_register_templates);
+
void crypto_unregister_template(struct crypto_template *tmpl)
{
struct crypto_instance *inst;
@@ -523,6 +541,15 @@ void crypto_unregister_template(struct crypto_template *tmpl)
}
EXPORT_SYMBOL_GPL(crypto_unregister_template);
+void crypto_unregister_templates(struct crypto_template *tmpls, int count)
+{
+ int i;
+
+ for (i = count - 1; i >= 0; --i)
+ crypto_unregister_template(&tmpls[i]);
+}
+EXPORT_SYMBOL_GPL(crypto_unregister_templates);
+
static struct crypto_template *__crypto_lookup_template(const char *name)
{
struct crypto_template *q, *tmpl = NULL;