Skip to content

Commit 1f6669b

Browse files
montjoieherbertx
authored andcommitted
crypto: user - Add crypto_stats_init
This patch add the crypto_stats_init() function. This will permit to remove some ifdef from __crypto_register_alg(). Signed-off-by: Corentin Labbe <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 44f1313 commit 1f6669b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

crypto/algapi.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
258258
list_add(&alg->cra_list, &crypto_alg_list);
259259
list_add(&larval->alg.cra_list, &crypto_alg_list);
260260

261-
#ifdef CONFIG_CRYPTO_STATS
262-
memset(&alg->stats, 0, sizeof(alg->stats));
263-
#endif
261+
crypto_stats_init(alg);
264262

265263
out:
266264
return larval;
@@ -1073,6 +1071,12 @@ int crypto_type_has_alg(const char *name, const struct crypto_type *frontend,
10731071
EXPORT_SYMBOL_GPL(crypto_type_has_alg);
10741072

10751073
#ifdef CONFIG_CRYPTO_STATS
1074+
void crypto_stats_init(struct crypto_alg *alg)
1075+
{
1076+
memset(&alg->stats, 0, sizeof(alg->stats));
1077+
}
1078+
EXPORT_SYMBOL_GPL(crypto_stats_init);
1079+
10761080
void crypto_stats_get(struct crypto_alg *alg)
10771081
{
10781082
crypto_alg_get(alg);

include/linux/crypto.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ struct crypto_alg {
614614
} CRYPTO_MINALIGN_ATTR;
615615

616616
#ifdef CONFIG_CRYPTO_STATS
617+
void crypto_stats_init(struct crypto_alg *alg);
617618
void crypto_stats_get(struct crypto_alg *alg);
618619
void crypto_stats_ablkcipher_encrypt(unsigned int nbytes, int ret, struct crypto_alg *alg);
619620
void crypto_stats_ablkcipher_decrypt(unsigned int nbytes, int ret, struct crypto_alg *alg);
@@ -635,6 +636,8 @@ void crypto_stats_rng_generate(struct crypto_alg *alg, unsigned int dlen, int re
635636
void crypto_stats_skcipher_encrypt(unsigned int cryptlen, int ret, struct crypto_alg *alg);
636637
void crypto_stats_skcipher_decrypt(unsigned int cryptlen, int ret, struct crypto_alg *alg);
637638
#else
639+
static inline void crypto_stats_init(struct crypto_alg *alg)
640+
{}
638641
static inline void crypto_stats_get(struct crypto_alg *alg)
639642
{}
640643
static inline void crypto_stats_ablkcipher_encrypt(unsigned int nbytes, int ret, struct crypto_alg *alg)

0 commit comments

Comments
 (0)