aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorXiongfeng Wang <xiongfeng.wang@linaro.org>2019-01-18 13:58:14 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2019-01-25 18:41:52 +0800
commit9f8ef365ef3d8bb157b800b1be30e335416701c2 (patch)
tree470e153295184f9730b83a3992557ecf28b47c00 /crypto
parentcrypto: gcm - use template array registering API to simplify the code (diff)
downloadlinux-dev-9f8ef365ef3d8bb157b800b1be30e335416701c2.tar.xz
linux-dev-9f8ef365ef3d8bb157b800b1be30e335416701c2.zip
crypto: ctr - use template array registering API to simplify the code
Use crypto template array registering API 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/ctr.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/crypto/ctr.c b/crypto/ctr.c
index 4c743a96faa4..ec8f8b67473a 100644
--- a/crypto/ctr.c
+++ b/crypto/ctr.c
@@ -171,12 +171,6 @@ out_put_alg:
return err;
}
-static struct crypto_template crypto_ctr_tmpl = {
- .name = "ctr",
- .create = crypto_ctr_create,
- .module = THIS_MODULE,
-};
-
static int crypto_rfc3686_setkey(struct crypto_skcipher *parent,
const u8 *key, unsigned int keylen)
{
@@ -366,36 +360,28 @@ err_free_inst:
goto out;
}
-static struct crypto_template crypto_rfc3686_tmpl = {
- .name = "rfc3686",
- .create = crypto_rfc3686_create,
- .module = THIS_MODULE,
+static struct crypto_template crypto_ctr_tmpls[] = {
+ {
+ .name = "ctr",
+ .create = crypto_ctr_create,
+ .module = THIS_MODULE,
+ }, {
+ .name = "rfc3686",
+ .create = crypto_rfc3686_create,
+ .module = THIS_MODULE,
+ },
};
static int __init crypto_ctr_module_init(void)
{
- int err;
-
- err = crypto_register_template(&crypto_ctr_tmpl);
- if (err)
- goto out;
-
- err = crypto_register_template(&crypto_rfc3686_tmpl);
- if (err)
- goto out_drop_ctr;
-
-out:
- return err;
-
-out_drop_ctr:
- crypto_unregister_template(&crypto_ctr_tmpl);
- goto out;
+ return crypto_register_templates(crypto_ctr_tmpls,
+ ARRAY_SIZE(crypto_ctr_tmpls));
}
static void __exit crypto_ctr_module_exit(void)
{
- crypto_unregister_template(&crypto_rfc3686_tmpl);
- crypto_unregister_template(&crypto_ctr_tmpl);
+ crypto_unregister_templates(crypto_ctr_tmpls,
+ ARRAY_SIZE(crypto_ctr_tmpls));
}
module_init(crypto_ctr_module_init);