1
0
Fork 0

hwrng: timeriomem - relax check on memory resource size

The timeriomem_rng driver only accesses the first 4 bytes of the given
memory area and currently, it also forces that memory resource to be
exactly 4 bytes in size.

This, however, is problematic when used with device-trees that are
generated from things like FPGA toolchains, where the minimum size
of an exposed memory block may be something like 4k.

Hence, let's only check for what's needed for the driver to operate
properly; namely that we have enough memory available to read the
random data from.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
alistair/sunxi64-5.4-dsi
Daniel Mack 2019-08-31 13:55:55 +02:00 committed by Herbert Xu
parent 4eb76faff8
commit 2a4bfd023f
2 changed files with 3 additions and 3 deletions

View File

@ -12,7 +12,7 @@ Optional properties:
which disables using this rng to automatically fill the kernel's
entropy pool.
N.B. currently 'reg' must be four bytes wide and aligned
N.B. currently 'reg' must be at least four bytes wide and 32-bit aligned
Example:

View File

@ -117,9 +117,9 @@ static int timeriomem_rng_probe(struct platform_device *pdev)
if (!res)
return -ENXIO;
if (res->start % 4 != 0 || resource_size(res) != 4) {
if (res->start % 4 != 0 || resource_size(res) < 4) {
dev_err(&pdev->dev,
"address must be four bytes wide and aligned\n");
"address must be at least four bytes wide and 32-bit aligned\n");
return -EINVAL;
}