Skip to content

Commit a5e7a2d

Browse files
jkivilinherbertx
authored andcommitted
crypto: tiger - use crypto_[un]register_shashes
Combine all shash algs to be registered and use new crypto_[un]register_shashes functions. This simplifies init/exit code. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 50fc3e8 commit a5e7a2d

1 file changed

Lines changed: 6 additions & 32 deletions

File tree

‎crypto/tgr192.c‎

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ static int tgr128_final(struct shash_desc *desc, u8 * out)
628628
return 0;
629629
}
630630

631-
static struct shash_alg tgr192 = {
631+
static struct shash_alg tgr_algs[3] = { {
632632
.digestsize = TGR192_DIGEST_SIZE,
633633
.init = tgr192_init,
634634
.update = tgr192_update,
@@ -640,9 +640,7 @@ static struct shash_alg tgr192 = {
640640
.cra_blocksize = TGR192_BLOCK_SIZE,
641641
.cra_module = THIS_MODULE,
642642
}
643-
};
644-
645-
static struct shash_alg tgr160 = {
643+
}, {
646644
.digestsize = TGR160_DIGEST_SIZE,
647645
.init = tgr192_init,
648646
.update = tgr192_update,
@@ -654,9 +652,7 @@ static struct shash_alg tgr160 = {
654652
.cra_blocksize = TGR192_BLOCK_SIZE,
655653
.cra_module = THIS_MODULE,
656654
}
657-
};
658-
659-
static struct shash_alg tgr128 = {
655+
}, {
660656
.digestsize = TGR128_DIGEST_SIZE,
661657
.init = tgr192_init,
662658
.update = tgr192_update,
@@ -668,38 +664,16 @@ static struct shash_alg tgr128 = {
668664
.cra_blocksize = TGR192_BLOCK_SIZE,
669665
.cra_module = THIS_MODULE,
670666
}
671-
};
667+
} };
672668

673669
static int __init tgr192_mod_init(void)
674670
{
675-
int ret = 0;
676-
677-
ret = crypto_register_shash(&tgr192);
678-
679-
if (ret < 0) {
680-
goto out;
681-
}
682-
683-
ret = crypto_register_shash(&tgr160);
684-
if (ret < 0) {
685-
crypto_unregister_shash(&tgr192);
686-
goto out;
687-
}
688-
689-
ret = crypto_register_shash(&tgr128);
690-
if (ret < 0) {
691-
crypto_unregister_shash(&tgr192);
692-
crypto_unregister_shash(&tgr160);
693-
}
694-
out:
695-
return ret;
671+
return crypto_register_shashes(tgr_algs, ARRAY_SIZE(tgr_algs));
696672
}
697673

698674
static void __exit tgr192_mod_fini(void)
699675
{
700-
crypto_unregister_shash(&tgr192);
701-
crypto_unregister_shash(&tgr160);
702-
crypto_unregister_shash(&tgr128);
676+
crypto_unregister_shashes(tgr_algs, ARRAY_SIZE(tgr_algs));
703677
}
704678

705679
MODULE_ALIAS("tgr160");

0 commit comments

Comments
 (0)