lkml.org 
[lkml]   [2012]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] i.MX31: mxc-rnga: implement waiting for data in driver
Date
On Tuesday 21 February 2012, Michael Thalmeier wrote:
> On 2012-02-21 14:29, Fabio Estevam wrote:
>
> > On Tue, Feb 21, 2012 at 10:13 AM, Michael Thalmeier
> > <michael.thalmeier@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)
> >
> I am absolutely with you.
> The point is only that this is the behaviour of nearly all hw_random
> drivers, and I basically just copied it over into this driver.

Hmm, I guess they are all wrong then ;-)

It would be nice to move the retry loop into common code where it
would be easier to change.

Note that comparing jiffies is not going to help here because the
maximum delay in the loop is less than a jiffy.

Arnd


\
 
 \ /
  Last update: 2012-02-23 14:39    [W:0.036 / U:4.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site