Skip to content

Commit 167e24e

Browse files
committed
bcm2835-rng: Avoid initialising if already enabled
Avoids the 0x40000 cycles of warmup again if firmware has already used it
1 parent 361b309 commit 167e24e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/char/hw_random/bcm2835-rng.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ static int bcm2835_rng_init(struct hwrng *rng)
107107
}
108108

109109
/* set warm-up count & enable */
110-
rng_writel(priv, RNG_WARMUP_COUNT, RNG_STATUS);
111-
rng_writel(priv, RNG_RBGEN, RNG_CTRL);
110+
if (!(rng_readl(priv, RNG_CTRL) & RNG_RBGEN)) {
111+
rng_writel(priv, RNG_WARMUP_COUNT, RNG_STATUS);
112+
rng_writel(priv, RNG_RBGEN, RNG_CTRL);
113+
}
112114

113115
return ret;
114116
}

0 commit comments

Comments
 (0)