bcm2835-rng: Avoid initialising if already enabled
authorpopcornmix <popcornmix@gmail.com>
Tue, 6 Dec 2016 17:05:39 +0000 (17:05 +0000)
committerpopcornmix <popcornmix@gmail.com>
Mon, 13 May 2019 23:07:52 +0000 (00:07 +0100)
Avoids the 0x40000 cycles of warmup again if firmware has already used it

drivers/char/hw_random/bcm2835-rng.c

index 6767d96..186fe2f 100644 (file)
@@ -105,8 +105,10 @@ static int bcm2835_rng_init(struct hwrng *rng)
        }
 
        /* set warm-up count & enable */
-       rng_writel(priv, RNG_WARMUP_COUNT, RNG_STATUS);
-       rng_writel(priv, RNG_RBGEN, RNG_CTRL);
+       if (!(rng_readl(priv, RNG_CTRL) & RNG_RBGEN)) {
+               rng_writel(priv, RNG_WARMUP_COUNT, RNG_STATUS);
+               rng_writel(priv, RNG_RBGEN, RNG_CTRL);
+       }
 
        return ret;
 }