diff options
author | Patrick McHardy <kaber@trash.net> | 2007-11-21 05:24:45 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-01-10 22:16:16 +0100 |
commit | 984e976f5382ff09351ddd3b023937611396d739 (patch) | |
tree | 2fcce0de19b06547772f015b8409efc3d2c8d52a /drivers/char/hw_random/pasemi-rng.c | |
parent | [CRYPTO] salsa20: Salsa20 stream cipher (diff) | |
download | linux-984e976f5382ff09351ddd3b023937611396d739.tar.xz linux-984e976f5382ff09351ddd3b023937611396d739.zip |
[HWRNG]: move status polling loop to data_present callbacks
Handle waiting for new random within the drivers themselves, this allows to
use better suited timeouts for the individual rngs.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Acked-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char/hw_random/pasemi-rng.c')
-rw-r--r-- | drivers/char/hw_random/pasemi-rng.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/char/hw_random/pasemi-rng.c b/drivers/char/hw_random/pasemi-rng.c index fa6040b6c8f2..621adf25e580 100644 --- a/drivers/char/hw_random/pasemi-rng.c +++ b/drivers/char/hw_random/pasemi-rng.c @@ -23,6 +23,7 @@ #include <linux/kernel.h> #include <linux/platform_device.h> #include <linux/hw_random.h> +#include <linux/delay.h> #include <asm/of_platform.h> #include <asm/io.h> @@ -44,9 +45,16 @@ static int pasemi_rng_data_present(struct hwrng *rng) { void __iomem *rng_regs = (void __iomem *)rng->priv; - - return (in_le32(rng_regs + SDCRNG_CTL_REG) - & SDCRNG_CTL_FVLD_M) ? 1 : 0; + int data, i; + + for (i = 0; i < 20; i++) { + data = (in_le32(rng_regs + SDCRNG_CTL_REG) + & SDCRNG_CTL_FVLD_M) ? 1 : 0; + if (data || !wait) + break; + udelay(10); + } + return data; } static int pasemi_rng_data_read(struct hwrng *rng, u32 *data) |