aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorAlexander Clouter <alex@digriz.org.uk>2013-03-31 12:34:51 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2013-04-25 09:01:46 -0400
commitb149a30d87d165e1079163fdab6f14e48b2f57b2 (patch)
treed6ced5787f9831ea9daa759bd600de59a4705a65 /drivers/char
parent1907da78bf6a3f74e5d030a4a4f6700ba0d0a234 (diff)
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')
-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 9dd2cadc31bd..3e75737f5fe1 100644
--- a/drivers/char/hw_random/timeriomem-rng.c
+++ b/drivers/char/hw_random/timeriomem-rng.c
@@ -23,6 +23,7 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/of.h>
26#include <linux/hw_random.h> 27#include <linux/hw_random.h>
27#include <linux/io.h> 28#include <linux/io.h>
28#include <linux/slab.h> 29#include <linux/slab.h>
@@ -101,7 +102,7 @@ static int timeriomem_rng_probe(struct platform_device *pdev)
101 int err = 0; 102 int err = 0;
102 int period; 103 int period;
103 104
104 if (!pdata) { 105 if (!pdev->dev.of_node && !pdata) {
105 dev_err(&pdev->dev, "timeriomem_rng_data is missing\n"); 106 dev_err(&pdev->dev, "timeriomem_rng_data is missing\n");
106 return -EINVAL; 107 return -EINVAL;
107 } 108 }
@@ -125,7 +126,19 @@ static int timeriomem_rng_probe(struct platform_device *pdev)
125 126
126 platform_set_drvdata(pdev, priv); 127 platform_set_drvdata(pdev, priv);
127 128
128 period = pdata->period; 129 if (pdev->dev.of_node) {
130 int i;
131
132 if (!of_property_read_u32(pdev->dev.of_node,
133 "period", &i))
134 period = i;
135 else {
136 dev_err(&pdev->dev, "missing period\n");
137 err = -EINVAL;
138 goto out_free;
139 }
140 } else
141 period = pdata->period;
129 142
130 priv->period = usecs_to_jiffies(period); 143 priv->period = usecs_to_jiffies(period);
131 if (priv->period < 1) { 144 if (priv->period < 1) {
@@ -202,10 +215,17 @@ static int timeriomem_rng_remove(struct platform_device *pdev)
202 return 0; 215 return 0;
203} 216}
204 217
218static const struct of_device_id timeriomem_rng_match[] = {
219 { .compatible = "timeriomem_rng" },
220 {},
221};
222MODULE_DEVICE_TABLE(of, timeriomem_rng_match);
223
205static struct platform_driver timeriomem_rng_driver = { 224static struct platform_driver timeriomem_rng_driver = {
206 .driver = { 225 .driver = {
207 .name = "timeriomem_rng", 226 .name = "timeriomem_rng",
208 .owner = THIS_MODULE, 227 .owner = THIS_MODULE,
228 .of_match_table = timeriomem_rng_match,
209 }, 229 },
210 .probe = timeriomem_rng_probe, 230 .probe = timeriomem_rng_probe,
211 .remove = timeriomem_rng_remove, 231 .remove = timeriomem_rng_remove,