]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
hwrng: timeriomem - Fix cooldown period calculation
authorJan Henrik Weinstock <jan.weinstock@rwth-aachen.de>
Mon, 1 Feb 2021 15:14:59 +0000 (16:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Mar 2021 08:39:41 +0000 (09:39 +0100)
[ Upstream commit e145f5565dc48ccaf4cb50b7cfc48777bed8c100 ]

Ensure cooldown period tolerance of 1% is actually accounted for.

Fixes: ca3bff70ab32 ("hwrng: timeriomem - Improve performance...")
Signed-off-by: Jan Henrik Weinstock <jan.weinstock@rwth-aachen.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/hw_random/timeriomem-rng.c

index f615684028af710fc6a6db109c2f88282b4d6cf6..ba01f24db6db03e2891fdc193033d10edd397343 100644 (file)
@@ -72,7 +72,7 @@ static int timeriomem_rng_read(struct hwrng *hwrng, void *data,
                 */
                if (retval > 0)
                        usleep_range(period_us,
-                                       period_us + min(1, period_us / 100));
+                                       period_us + max(1, period_us / 100));
 
                *(u32 *)data = readl(priv->io_base);
                retval += sizeof(u32);