]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/hw_random/omap-rng.c
[HWRNG]: move status polling loop to data_present callbacks
[linux-2.6-omap-h63xx.git] / drivers / char / hw_random / omap-rng.c
index 3f35a1c562b1a1bb6c1fa211577caa87ac92c015..7e319951fa4111fec37688f052596a29cd27c211 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/hw_random.h>
+#include <linux/delay.h>
 
 #include <asm/io.h>
 
@@ -65,9 +66,17 @@ static void omap_rng_write_reg(int reg, u32 val)
 }
 
 /* REVISIT: Does the status bit really work on 16xx? */
-static int omap_rng_data_present(struct hwrng *rng)
+static int omap_rng_data_present(struct hwrng *rng, int wait)
 {
-       return omap_rng_read_reg(RNG_STAT_REG) ? 0 : 1;
+       int data, i;
+
+       for (i = 0; i < 20; i++) {
+               data = omap_rng_read_reg(RNG_STAT_REG) ? 0 : 1;
+               if (data || !wait)
+                       break;
+               udelay(10);
+       }
+       return data;
 }
 
 static int omap_rng_data_read(struct hwrng *rng, u32 *data)