Commit 1a5e02b6 authored by Xiongfeng Wang's avatar Xiongfeng Wang Committed by Herbert Xu

crypto: chacha20poly1305 - use template array registering API to simplify the code

Use crypto template array registering API to simplify the code.
Signed-off-by: default avatarXiongfeng Wang <xiongfeng.wang@linaro.org>
Reviewed-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 9f8ef365
...@@ -701,37 +701,28 @@ static int rfc7539esp_create(struct crypto_template *tmpl, struct rtattr **tb) ...@@ -701,37 +701,28 @@ static int rfc7539esp_create(struct crypto_template *tmpl, struct rtattr **tb)
return chachapoly_create(tmpl, tb, "rfc7539esp", 8); return chachapoly_create(tmpl, tb, "rfc7539esp", 8);
} }
static struct crypto_template rfc7539_tmpl = { static struct crypto_template rfc7539_tmpls[] = {
{
.name = "rfc7539", .name = "rfc7539",
.create = rfc7539_create, .create = rfc7539_create,
.module = THIS_MODULE, .module = THIS_MODULE,
}; }, {
static struct crypto_template rfc7539esp_tmpl = {
.name = "rfc7539esp", .name = "rfc7539esp",
.create = rfc7539esp_create, .create = rfc7539esp_create,
.module = THIS_MODULE, .module = THIS_MODULE,
},
}; };
static int __init chacha20poly1305_module_init(void) static int __init chacha20poly1305_module_init(void)
{ {
int err; return crypto_register_templates(rfc7539_tmpls,
ARRAY_SIZE(rfc7539_tmpls));
err = crypto_register_template(&rfc7539_tmpl);
if (err)
return err;
err = crypto_register_template(&rfc7539esp_tmpl);
if (err)
crypto_unregister_template(&rfc7539_tmpl);
return err;
} }
static void __exit chacha20poly1305_module_exit(void) static void __exit chacha20poly1305_module_exit(void)
{ {
crypto_unregister_template(&rfc7539esp_tmpl); crypto_unregister_templates(rfc7539_tmpls,
crypto_unregister_template(&rfc7539_tmpl); ARRAY_SIZE(rfc7539_tmpls));
} }
module_init(chacha20poly1305_module_init); module_init(chacha20poly1305_module_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment