Re: [PATCH] i.MX31: mxc-rnga: implement waiting for data in driver

From: Fabio Estevam
Date: Tue Feb 21 2012 - 08:29:07 EST


On Tue, Feb 21, 2012 at 10:13 AM, Michael Thalmeier
<michael.thalmeier@xxxxxxx> wrote:

> -static int mxc_rnga_data_present(struct hwrng *rng)
> +static int mxc_rnga_data_present(struct hwrng *rng, int wait)

This looks good, but ...

> Â{
> - Â Â Â int level;
> + Â Â Â int level, i;
> Â Â Â Âvoid __iomem *rng_base = (void __iomem *)rng->priv;
>
> - Â Â Â /* how many random numbers is in FIFO? [0-16] */
> - Â Â Â level = ((__raw_readl(rng_base + RNGA_STATUS) &
> - Â Â Â Â Â Â Â Â Â Â Â RNGA_STATUS_LEVEL_MASK) >> 8);
> + Â Â Â for (i = 0; i < 20; i++) {

Why the magic "20" here?

It would be better to add a proper timeout mechanism instead, such as
time_after(jiffies, timeout)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/