Commit 593c76e1 authored by Ovidiu Panait's avatar Ovidiu Panait Committed by Herbert Xu
Browse files

crypto: sun8i-ce-hash - add IS_ENABLED() checks to debugfs stats



Add IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG) checks before the
fallback counter updates to make sure the code is not included when
debugfs statistics support is not enabled.

Signed-off-by: default avatarOvidiu Panait <ovidiu.panait.oss@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent a8632253
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -60,7 +60,9 @@ int sun8i_ce_hash_init_tfm(struct crypto_ahash *tfm)
				 sizeof(struct sun8i_ce_hash_reqctx) +
				 crypto_ahash_reqsize(op->fallback_tfm));

	memcpy(algt->fbname, crypto_ahash_driver_name(op->fallback_tfm),
	if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
		memcpy(algt->fbname,
		       crypto_ahash_driver_name(op->fallback_tfm),
		       CRYPTO_MAX_ALG_NAME);

	err = pm_runtime_get_sync(op->ce->dev);
@@ -198,22 +200,30 @@ static bool sun8i_ce_hash_need_fallback(struct ahash_request *areq)
	algt = container_of(alg, struct sun8i_ce_alg_template, alg.hash.base);

	if (areq->nbytes == 0) {
		if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
			algt->stat_fb_len0++;

		return true;
	}
	/* we need to reserve one SG for padding one */
	if (sg_nents_for_len(areq->src, areq->nbytes) > MAX_SG - 1) {
		if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
			algt->stat_fb_maxsg++;

		return true;
	}
	sg = areq->src;
	while (sg) {
		if (sg->length % 4) {
			if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
				algt->stat_fb_srclen++;

			return true;
		}
		if (!IS_ALIGNED(sg->offset, sizeof(u32))) {
			if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
				algt->stat_fb_srcali++;

			return true;
		}
		sg = sg_next(sg);