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

Fabio Estevam festevam at gmail.com
Tue Feb 21 08:29:07 EST 2012


On Tue, Feb 21, 2012 at 10:13 AM, Michael Thalmeier
<michael.thalmeier at hale.at> 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)



More information about the linux-arm-kernel mailing list