diff options
author | Patrick McHardy <kaber@trash.net> | 2007-11-20 23:24:45 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-01-10 16:16:16 -0500 |
commit | 984e976f5382ff09351ddd3b023937611396d739 (patch) | |
tree | 2fcce0de19b06547772f015b8409efc3d2c8d52a /drivers/char/hw_random/geode-rng.c | |
parent | 2407d60872dd2a95404c6048f775f3b64d438f4b (diff) |
[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/geode-rng.c')
-rw-r--r-- | drivers/char/hw_random/geode-rng.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/char/hw_random/geode-rng.c b/drivers/char/hw_random/geode-rng.c index 8e8658dcd2e3..fed4ef5569f5 100644 --- a/drivers/char/hw_random/geode-rng.c +++ b/drivers/char/hw_random/geode-rng.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/hw_random.h> | 30 | #include <linux/hw_random.h> |
31 | #include <linux/delay.h> | ||
31 | #include <asm/io.h> | 32 | #include <asm/io.h> |
32 | 33 | ||
33 | 34 | ||
@@ -61,11 +62,18 @@ static int geode_rng_data_read(struct hwrng *rng, u32 *data) | |||
61 | return 4; | 62 | return 4; |
62 | } | 63 | } |
63 | 64 | ||
64 | static int geode_rng_data_present(struct hwrng *rng) | 65 | static int geode_rng_data_present(struct hwrng *rng, int wait) |
65 | { | 66 | { |
66 | void __iomem *mem = (void __iomem *)rng->priv; | 67 | void __iomem *mem = (void __iomem *)rng->priv; |
68 | int data, i; | ||
67 | 69 | ||
68 | return !!(readl(mem + GEODE_RNG_STATUS_REG)); | 70 | for (i = 0; i < 20; i++) { |
71 | data = !!(readl(mem + GEODE_RNG_STATUS_REG)); | ||
72 | if (data || !wait) | ||
73 | break; | ||
74 | udelay(10); | ||
75 | } | ||
76 | return data; | ||
69 | } | 77 | } |
70 | 78 | ||
71 | 79 | ||