Skip to content

Commit 830c04f

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 a5ebb39 commit 830c04f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/char/hw_random/bcm2835-rng.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
6262
bcm2835_rng_ops.priv = (unsigned long)rng_base;
6363

6464
/* set warm-up count & enable */
65-
__raw_writel(RNG_WARMUP_COUNT, rng_base + RNG_STATUS);
66-
__raw_writel(RNG_RBGEN, rng_base + RNG_CTRL);
67-
65+
if (!(__raw_readl(rng_base + RNG_CTRL) & RNG_RBGEN)) {
66+
__raw_writel(RNG_WARMUP_COUNT, rng_base + RNG_STATUS);
67+
__raw_writel(RNG_RBGEN, rng_base + RNG_CTRL);
68+
}
6869
/* register driver */
6970
err = hwrng_register(&bcm2835_rng_ops);
7071
if (err) {

0 commit comments

Comments
 (0)