diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-11-22 09:47:07 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-11-25 08:42:49 +0100 |
commit | 47ce6c75b5176ea642f0d38042aaffcc0fd1ee20 (patch) | |
tree | dfff6aaca20613423365c4fa9191e1fbed7fe935 | |
parent | db23ff0e450ef028af2aab49abce0d2947dc0e86 (diff) | |
download | barebox-47ce6c75b5176ea642f0d38042aaffcc0fd1ee20.tar.gz barebox-47ce6c75b5176ea642f0d38042aaffcc0fd1ee20.tar.xz |
hw_random: stm32: propagate error codes from rng read
len is never decremented, so ret won't ever be returned, fix this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20211122084732.2597109-6-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/hw_random/stm32-rng.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/hw_random/stm32-rng.c b/drivers/hw_random/stm32-rng.c index 440b53684f..9b28f37ecd 100644 --- a/drivers/hw_random/stm32-rng.c +++ b/drivers/hw_random/stm32-rng.c @@ -51,7 +51,7 @@ static int stm32_rng_read(struct hwrng *hwrng, void *data, size_t len, bool wait ret = readl_poll_timeout(rng->base + RNG_SR, sr, sr & RNG_SR_DRDY, 10 * USEC_PER_MSEC); if (ret) - goto out; + return ret; if (sr & (RNG_SR_SEIS | RNG_SR_SECS)) { int i; @@ -61,8 +61,7 @@ static int stm32_rng_read(struct hwrng *hwrng, void *data, size_t len, bool wait readl(rng->base + RNG_DR); if (readl(rng->base + RNG_SR) & RNG_SR_SEIS) { pr_warn("RNG Noise"); - ret = -EIO; - goto out; + return -EIO; } /* start again */ @@ -84,8 +83,7 @@ static int stm32_rng_read(struct hwrng *hwrng, void *data, size_t len, bool wait } } -out: - return len ?: ret; + return len; } static int stm32_rng_init(struct hwrng *hwrng) |