hw_random: timeriomem_rng: Allow setting RNG quality from platform data
authorRick Altherr <raltherr@google.com>
Mon, 22 May 2017 21:12:24 +0000 (14:12 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 1 Jun 2017 04:55:58 +0000 (12:55 +0800)
When a hw_random device's quality is non-zero, it will automatically be
used to fill the kernel's entropy pool.  Since timeriomem_rng is used by
many different devices, the quality needs to be provided by platform
data or device tree.

Signed-off-by: Rick Altherr <raltherr@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/char/hw_random/timeriomem-rng.c
include/linux/timeriomem-rng.h

index a0faa5f05debae1934063d7267b21d3a9e249405..03ff5483d8654b069d287a12139c1bf57cb12982 100644 (file)
@@ -151,8 +151,15 @@ static int timeriomem_rng_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev, "missing period\n");
                        return -EINVAL;
                }
+
+               if (!of_property_read_u32(pdev->dev.of_node,
+                                               "quality", &i))
+                       priv->rng_ops.quality = i;
+               else
+                       priv->rng_ops.quality = 0;
        } else {
                period = pdata->period;
+               priv->rng_ops.quality = pdata->quality;
        }
 
        priv->period = ns_to_ktime(period * NSEC_PER_USEC);
index 46eb27ddbfabbe96971733abd1285f53f78bbca8..3e00122bcf887d6ef15c46f1b2df7f3cfb51381d 100644 (file)
@@ -13,4 +13,7 @@ struct timeriomem_rng_data {
 
        /* measures in usecs */
        unsigned int            period;
+
+       /* bits of entropy per 1024 bits read */
+       unsigned int            quality;
 };