summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>2015-10-19 06:37:40 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2015-10-20 16:13:59 +0200
commitd7fd6075a205f19cd0c570c8b5badb8c69321d88 (patch)
treee97a6a45a944b77072125790a921cff7b1c6d3c8 /drivers/char
parentdt-bindings: rng: Describe Exynos4 PRNG bindings (diff)
downloadlinux-d7fd6075a205f19cd0c570c8b5badb8c69321d88.tar.xz
linux-d7fd6075a205f19cd0c570c8b5badb8c69321d88.zip
hwrng: exynos - Add timeout for waiting on init done
Driver may hang waiting indefinitely for PRNG to finish its initialization stage. Instead of stalling return -ETIMEDOUT error. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hw_random/exynos-rng.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c
index 73318e2a34dd..c117463642e3 100644
--- a/drivers/char/hw_random/exynos-rng.c
+++ b/drivers/char/hw_random/exynos-rng.c
@@ -81,14 +81,17 @@ static int exynos_read(struct hwrng *rng, void *buf,
struct exynos_rng *exynos_rng = container_of(rng,
struct exynos_rng, rng);
u32 *data = buf;
+ int retry = 100;
pm_runtime_get_sync(exynos_rng->dev);
exynos_rng_writel(exynos_rng, PRNG_START, 0);
while (!(exynos_rng_readl(exynos_rng,
- EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE))
+ EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE) && --retry)
cpu_relax();
+ if (!retry)
+ return -ETIMEDOUT;
exynos_rng_writel(exynos_rng, PRNG_DONE, EXYNOS_PRNG_STATUS_OFFSET);