From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: Michael Thalmeier <michael.thalmeier@hale.at>,
Fabio Estevam <festevam@gmail.com>,
michael@thalmeier.at, Sascha Hauer <s.hauer@pengutronix.de>,
linux-kernel@vger.kernel.org, Matt Mackall <mpm@selenic.com>
Subject: Re: [PATCH] i.MX31: mxc-rnga: implement waiting for data in driver
Date: Thu, 23 Feb 2012 13:37:19 +0000 [thread overview]
Message-ID: <201202231337.20052.arnd@arndb.de> (raw)
In-Reply-To: <4F43AC8D.5090508@hale.at>
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
prev parent reply other threads:[~2012-02-23 13:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-21 12:13 [PATCH] i.MX31: mxc-rnga: implement waiting for data in driver Michael Thalmeier
2012-02-21 13:29 ` Fabio Estevam
2012-02-21 14:39 ` Michael Thalmeier
2012-02-23 13:37 ` Arnd Bergmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201202231337.20052.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=festevam@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.thalmeier@hale.at \
--cc=michael@thalmeier.at \
--cc=mpm@selenic.com \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox