[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZG3fNmNfUHeWIsNZ@gondor.apana.org.au>
Date: Wed, 24 May 2023 17:56:06 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Bharat Bhushan <bbhushan2@...vell.com>
Cc: olivia@...enic.com, Jason@...c4.com, linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org, sgoutham@...vell.com
Subject: Re: [PATCH] hwrng: cn10k: Add extended trng register support
On Thu, May 18, 2023 at 12:17:34PM +0530, Bharat Bhushan wrote:
>
> -static void cn10k_read_trng(struct cn10k_rng *rng, u64 *value)
> +static size_t cn10k_read_trng(struct cn10k_rng *rng, u64 *value)
Since the return value is either 0 or 8, why did you pick size_t
as the return value?
> {
> + u16 retry_count = 0;
> u64 upper, lower;
> + u64 status;
> +
> + if (rng->extended_trng_regs) {
> + do {
> + *value = readq(rng->reg_base + RNM_PF_TRNG_DAT);
> + if (*value)
> + return 8;
> + status = readq(rng->reg_base + RNM_PF_TRNG_RES);
> + if (!status && (retry_count++ > 0x1000))
> + return 0;
> + } while (!status);
> + }
>
> *value = readq(rng->reg_base + RNM_PF_RANDOM);
>
> @@ -82,6 +130,7 @@ static void cn10k_read_trng(struct cn10k_rng *rng, u64 *value)
>
> *value = (upper & 0xFFFFFFFF00000000) | (lower & 0xFFFFFFFF);
> }
> + return 8;
> }
>
> static int cn10k_rng_read(struct hwrng *hwrng, void *data,
> @@ -100,7 +149,9 @@ static int cn10k_rng_read(struct hwrng *hwrng, void *data,
> size = max;
>
> while (size >= 8) {
> - cn10k_read_trng(rng, &value);
> + err = cn10k_read_trng(rng, &value);
> + if (!err)
> + goto out;
It appears that err is either 8 or 0, so it's not really an error.
Could you plesae use a more meaningful name for this variable?
Cheers,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists