All of lore.kernel.org
 help / color / mirror / Atom feed
From: benoit.thebaudeau@advansee.com (Benoît Thébaudeau)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: mxc-rnga: fix data_present API
Date: Tue, 12 Jun 2012 23:07:47 +0200 (CEST)	[thread overview]
Message-ID: <1795608889.2533817.1339535267600.JavaMail.root@advansee.com> (raw)

Cc: Matt Mackall <mpm@selenic.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: Alan Carvalho de Assis <acassis@gmail.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau@advansee.com>
---
 .../drivers/char/hw_random/mxc-rnga.c              |   22 +++++++++++++-------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git linux-next-HEAD-c90e5d2.orig/drivers/char/hw_random/mxc-rnga.c linux-next-HEAD-c90e5d2/drivers/char/hw_random/mxc-rnga.c
index 187c6be..2924253 100644
--- linux-next-HEAD-c90e5d2.orig/drivers/char/hw_random/mxc-rnga.c
+++ linux-next-HEAD-c90e5d2/drivers/char/hw_random/mxc-rnga.c
@@ -24,6 +24,7 @@
 #include <linux/ioport.h>
 #include <linux/platform_device.h>
 #include <linux/hw_random.h>
+#include <linux/delay.h>
 #include <linux/io.h>
 
 /* RNGA Registers */
@@ -60,16 +61,21 @@
 
 static struct platform_device *rng_dev;
 
-static int mxc_rnga_data_present(struct hwrng *rng)
+static int mxc_rnga_data_present(struct hwrng *rng, int wait)
 {
-	int level;
 	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);
-
-	return level > 0 ? 1 : 0;
+	int level, data, i;
+
+	for (i = 0; i < 20; i++) {
+		/* how many random numbers is in FIFO? [0-16] */
+		level = ((__raw_readl(rng_base + RNGA_STATUS) &
+				RNGA_STATUS_LEVEL_MASK) >> 8);
+		data = level > 0 ? 1 : 0;
+		if (data || !wait)
+			break;
+		udelay(10);
+	}
+	return data;
 }
 
 static int mxc_rnga_data_read(struct hwrng *rng, u32 * data)

             reply	other threads:[~2012-06-12 21:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-12 21:07 Benoît Thébaudeau [this message]
2012-06-12 21:12 ` [PATCH] ARM: mxc-rnga: fix data_present API Fabio Estevam
2012-06-12 21:25   ` Benoît Thébaudeau
2012-06-13  6:36 ` Uwe Kleine-König
2012-06-13 16:15   ` Benoît Thébaudeau
2012-06-27  6:48     ` Herbert Xu

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=1795608889.2533817.1339535267600.JavaMail.root@advansee.com \
    --to=benoit.thebaudeau@advansee.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.