summaryrefslogtreecommitdiffstats
path: root/drivers/char/hw_random
diff options
context:
space:
mode:
authorAlexander Clouter <alex@digriz.org.uk>2013-03-31 17:34:51 +0100
committerHerbert Xu <herbert@gondor.apana.org.au>2013-04-25 21:01:46 +0800
commitb149a30d87d165e1079163fdab6f14e48b2f57b2 (patch)
treed6ced5787f9831ea9daa759bd600de59a4705a65 /drivers/char/hw_random
parent1907da78bf6a3f74e5d030a4a4f6700ba0d0a234 (diff)
downloadop-kernel-dev-b149a30d87d165e1079163fdab6f14e48b2f57b2.zip
op-kernel-dev-b149a30d87d165e1079163fdab6f14e48b2f57b2.tar.gz
hwrng: timeriomem - added devicetree hooks
This patch allows timeriomem_rng to be used via devicetree. Signed-off-by: Alexander Clouter <alex@digriz.org.uk> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char/hw_random')
-rw-r--r--drivers/char/hw_random/timeriomem-rng.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/char/hw_random/timeriomem-rng.c b/drivers/char/hw_random/timeriomem-rng.c
index 9dd2cad..3e75737 100644
--- a/drivers/char/hw_random/timeriomem-rng.c
+++ b/drivers/char/hw_random/timeriomem-rng.c
@@ -23,6 +23,7 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
+#include <linux/of.h>
#include <linux/hw_random.h>
#include <linux/io.h>
#include <linux/slab.h>
@@ -101,7 +102,7 @@ static int timeriomem_rng_probe(struct platform_device *pdev)
int err = 0;
int period;
- if (!pdata) {
+ if (!pdev->dev.of_node && !pdata) {
dev_err(&pdev->dev, "timeriomem_rng_data is missing\n");
return -EINVAL;
}
@@ -125,7 +126,19 @@ static int timeriomem_rng_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv);
- period = pdata->period;
+ if (pdev->dev.of_node) {
+ int i;
+
+ if (!of_property_read_u32(pdev->dev.of_node,
+ "period", &i))
+ period = i;
+ else {
+ dev_err(&pdev->dev, "missing period\n");
+ err = -EINVAL;
+ goto out_free;
+ }
+ } else
+ period = pdata->period;
priv->period = usecs_to_jiffies(period);
if (priv->period < 1) {
@@ -202,10 +215,17 @@ static int timeriomem_rng_remove(struct platform_device *pdev)
return 0;
}
+static const struct of_device_id timeriomem_rng_match[] = {
+ { .compatible = "timeriomem_rng" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, timeriomem_rng_match);
+
static struct platform_driver timeriomem_rng_driver = {
.driver = {
.name = "timeriomem_rng",
.owner = THIS_MODULE,
+ .of_match_table = timeriomem_rng_match,
},
.probe = timeriomem_rng_probe,
.remove = timeriomem_rng_remove,
OpenPOWER on IntegriCloud