summaryrefslogtreecommitdiff
path: root/drivers/char/hw_random/omap3-rom-rng.c
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2019-09-15 00:02:55 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2019-10-04 18:06:10 +0300
commit0c0ef9ea6f3f0d5979dc7b094b0a184c1a94716b (patch)
tree897c63814fbe21be39891e33eeb3e02b659af73b /drivers/char/hw_random/omap3-rom-rng.c
parent7fb61afb7b5b4389e0f6e78c3a822d5991d4edef (diff)
downloadlinux-0c0ef9ea6f3f0d5979dc7b094b0a184c1a94716b.tar.xz
hwrng: omap3-rom - Fix missing clock by probing with device tree
Commit 0ed266d7ae5e ("clk: ti: omap3: cleanup unnecessary clock aliases") removed old omap3 clock framework aliases but caused omap3-rom-rng to stop working with clock not found error. Based on discussions on the mailing list it was requested by Tero Kristo that it would be best to fix this issue by probing omap3-rom-rng using device tree to provide a proper clk property. The other option would be to add back the missing clock alias, but that does not help moving things forward with removing old legacy platform_data. Let's also add a proper device tree binding and keep it together with the fix. Cc: devicetree@vger.kernel.org Cc: Aaro Koskinen <aaro.koskinen@iki.fi> Cc: Adam Ford <aford173@gmail.com> Cc: Pali Rohár <pali.rohar@gmail.com> Cc: Rob Herring <robh+dt@kernel.org> Cc: Sebastian Reichel <sre@kernel.org> Cc: Tero Kristo <t-kristo@ti.com> Fixes: 0ed266d7ae5e ("clk: ti: omap3: cleanup unnecessary clock aliases") Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Tony Lindgren <tony@atomide.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char/hw_random/omap3-rom-rng.c')
-rw-r--r--drivers/char/hw_random/omap3-rom-rng.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/char/hw_random/omap3-rom-rng.c b/drivers/char/hw_random/omap3-rom-rng.c
index 38b719017186..34e10f05545a 100644
--- a/drivers/char/hw_random/omap3-rom-rng.c
+++ b/drivers/char/hw_random/omap3-rom-rng.c
@@ -20,6 +20,8 @@
#include <linux/workqueue.h>
#include <linux/clk.h>
#include <linux/err.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#define RNG_RESET 0x01
@@ -86,14 +88,18 @@ static int omap3_rom_rng_read(struct hwrng *rng, void *data, size_t max, bool w)
static struct hwrng omap3_rom_rng_ops = {
.name = "omap3-rom",
- .read = omap3_rom_rng_read,
};
static int omap3_rom_rng_probe(struct platform_device *pdev)
{
int ret = 0;
- pr_info("initializing\n");
+ omap3_rom_rng_ops.read = of_device_get_match_data(&pdev->dev);
+ if (!omap3_rom_rng_ops.read) {
+ dev_err(&pdev->dev, "missing rom code handler\n");
+
+ return -ENODEV;
+ }
omap3_rom_rng_call = pdev->dev.platform_data;
if (!omap3_rom_rng_call) {
@@ -125,9 +131,16 @@ static int omap3_rom_rng_remove(struct platform_device *pdev)
return 0;
}
+static const struct of_device_id omap_rom_rng_match[] = {
+ { .compatible = "nokia,n900-rom-rng", .data = omap3_rom_rng_read, },
+ { /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, omap_rom_rng_match);
+
static struct platform_driver omap3_rom_rng_driver = {
.driver = {
.name = "omap3-rom-rng",
+ .of_match_table = omap_rom_rng_match,
},
.probe = omap3_rom_rng_probe,
.remove = omap3_rom_rng_remove,