]> git.baikalelectronics.ru Git - kernel.git/commit
hwrng: core - document the quality field
authorMichael S. Tsirkin <mst@redhat.com>
Tue, 25 Sep 2018 16:35:18 +0000 (12:35 -0400)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 5 Oct 2018 02:16:56 +0000 (10:16 +0800)
commit590ed2249c8e69ee444fb1061303fb4fdb1d88db
treee949847f12f61787a7dbb8a4d406fbe18c376ba4
parentcf14cbca7a33e60f66cc1344c5450c6580d00941
hwrng: core - document the quality field

quality field is currently documented as being 'per mill'.  In fact the
math involved is:

                add_hwgenerator_randomness((void *)rng_fillbuf, rc,
                                           rc * current_quality * 8 >> 10);

thus the actual definition is "bits of entropy per 1024 bits of input".

The current documentation seems to have confused multiple people
in the past, let's fix the documentation to match code.

An alternative is to change core to match driver expectations, replacing
rc * current_quality * 8 >> 10
with
rc * current_quality / 1000
but that has performance costs, so probably isn't a good option.

Fixes: 82b708c5371 ("hwrng: add per-device entropy derating")
Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/char/hw_random/core.c
include/linux/hw_random.h