diff options
author | Xiongfeng Wang <xiongfeng.wang@linaro.org> | 2019-01-18 00:58:14 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-01-25 05:41:52 -0500 |
commit | 9f8ef365ef3d8bb157b800b1be30e335416701c2 (patch) | |
tree | 470e153295184f9730b83a3992557ecf28b47c00 /crypto/ctr.c | |
parent | 56a00d9da159ad7a2e9cbd18a2db9165bf5c373b (diff) |
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/ctr.c')
-rw-r--r-- | crypto/ctr.c | 42 |
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: | |||
171 | return err; | 171 | return err; |
172 | } | 172 | } |
173 | 173 | ||
174 | static struct crypto_template crypto_ctr_tmpl = { | ||
175 | .name = "ctr", | ||
176 | .create = crypto_ctr_create, | ||
177 | .module = THIS_MODULE, | ||
178 | }; | ||
179 | |||
180 | static int crypto_rfc3686_setkey(struct crypto_skcipher *parent, | 174 | static int crypto_rfc3686_setkey(struct crypto_skcipher *parent, |
181 | const u8 *key, unsigned int keylen) | 175 | const u8 *key, unsigned int keylen) |
182 | { | 176 | { |
@@ -366,36 +360,28 @@ err_free_inst: | |||
366 | goto out; | 360 | goto out; |
367 | } | 361 | } |
368 | 362 | ||
369 | static struct crypto_template crypto_rfc3686_tmpl = { | 363 | static struct crypto_template crypto_ctr_tmpls[] = { |
370 | .name = "rfc3686", | 364 | { |
371 | .create = crypto_rfc3686_create, | 365 | .name = "ctr", |
372 | .module = THIS_MODULE, | 366 | .create = crypto_ctr_create, |
367 | .module = THIS_MODULE, | ||
368 | }, { | ||
369 | .name = "rfc3686", | ||
370 | .create = crypto_rfc3686_create, | ||
371 | .module = THIS_MODULE, | ||
372 | }, | ||
373 | }; | 373 | }; |
374 | 374 | ||
375 | static int __init crypto_ctr_module_init(void) | 375 | static int __init crypto_ctr_module_init(void) |
376 | { | 376 | { |
377 | int err; | 377 | return crypto_register_templates(crypto_ctr_tmpls, |
378 | 378 | ARRAY_SIZE(crypto_ctr_tmpls)); | |
379 | err = crypto_register_template(&crypto_ctr_tmpl); | ||
380 | if (err) | ||
381 | goto out; | ||
382 | |||
383 | err = crypto_register_template(&crypto_rfc3686_tmpl); | ||
384 | if (err) | ||
385 | goto out_drop_ctr; | ||
386 | |||
387 | out: | ||
388 | return err; | ||
389 | |||
390 | out_drop_ctr: | ||
391 | crypto_unregister_template(&crypto_ctr_tmpl); | ||
392 | goto out; | ||
393 | } | 379 | } |
394 | 380 | ||
395 | static void __exit crypto_ctr_module_exit(void) | 381 | static void __exit crypto_ctr_module_exit(void) |
396 | { | 382 | { |
397 | crypto_unregister_template(&crypto_rfc3686_tmpl); | 383 | crypto_unregister_templates(crypto_ctr_tmpls, |
398 | crypto_unregister_template(&crypto_ctr_tmpl); | 384 | ARRAY_SIZE(crypto_ctr_tmpls)); |
399 | } | 385 | } |
400 | 386 | ||
401 | module_init(crypto_ctr_module_init); | 387 | module_init(crypto_ctr_module_init); |