Re: [PATCH] hwrng: cn10k: Add extended trng register support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux