hwrng: core - allow perfect entropy from hardware devices
authorKeith Packard <keithp@keithp.com>
Wed, 18 Mar 2015 07:17:00 +0000 (00:17 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 18 Mar 2015 10:01:31 +0000 (21:01 +1100)
Hardware random number quality is measured from 0 (no entropy) to 1024
(perfect entropy). Allow hardware devices to assert the full range by
truncating the device-provided value at 1024 instead of 1023.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/char/hw_random/core.c

index 83161dde53eedc0acb0cbba938ddeacd6fb82cc6..571ef61f8ea94eb36bd34b4ab459b4c3435f5247 100644 (file)
@@ -179,7 +179,8 @@ skip_init:
        add_early_randomness(rng);
 
        current_quality = rng->quality ? : default_quality;
-       current_quality &= 1023;
+       if (current_quality > 1024)
+               current_quality = 1024;
 
        if (current_quality == 0 && hwrng_fill)
                kthread_stop(hwrng_fill);