[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190913220922.29501-4-tony@atomide.com>
Date: Fri, 13 Sep 2019 15:09:19 -0700
From: Tony Lindgren <tony@...mide.com>
To: Matt Mackall <mpm@...enic.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
linux-kernel@...r.kernel.org, linux-omap@...r.kernel.org
Cc: linux-crypto@...r.kernel.org, Aaro Koskinen <aaro.koskinen@....fi>,
Adam Ford <aford173@...il.com>,
Pali Rohár <pali.rohar@...il.com>,
Tero Kristo <t-kristo@...com>,
Rob Herring <robh+dt@...nel.org>, devicetree@...r.kernel.org
Subject: [PATCH 3/6] hwrng: omap3-rom - Call clk_prepare() on init and exit only
When unloading omap3-rom-rng, we'll get the following:
WARNING: CPU: 0 PID: 100 at drivers/clk/clk.c:948 clk_core_disable
This is because the clock is already disabled by omap3_rom_rng_idle().
Also, we should not call prepare and unprepare except during init, and
only call enable and disable during use.
Cc: Aaro Koskinen <aaro.koskinen@....fi>
Cc: Adam Ford <aford173@...il.com>
Cc: Pali Rohár <pali.rohar@...il.com>
Cc: Tero Kristo <t-kristo@...com>
Fixes: 1c6b7c2108bd ("hwrng: OMAP3 ROM Random Number Generator support")
Signed-off-by: Tony Lindgren <tony@...mide.com>
---
drivers/char/hw_random/omap3-rom-rng.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/char/hw_random/omap3-rom-rng.c b/drivers/char/hw_random/omap3-rom-rng.c
--- a/drivers/char/hw_random/omap3-rom-rng.c
+++ b/drivers/char/hw_random/omap3-rom-rng.c
@@ -44,7 +44,7 @@ static void omap3_rom_rng_idle(struct work_struct *work)
pr_err("reset failed: %d\n", r);
return;
}
- clk_disable_unprepare(rng_clk);
+ clk_disable(rng_clk);
rng_idle = 1;
}
@@ -55,13 +55,13 @@ static int omap3_rom_rng_get_random(void *buf, unsigned int count)
cancel_delayed_work_sync(&idle_work);
if (rng_idle) {
- r = clk_prepare_enable(rng_clk);
+ r = clk_enable(rng_clk);
if (r)
return r;
r = omap3_rom_rng_call(0, 0, RNG_GEN_PRNG_HW_INIT);
if (r != 0) {
- clk_disable_unprepare(rng_clk);
+ clk_disable(rng_clk);
pr_err("HW init failed: %d\n", r);
return -EIO;
}
@@ -114,20 +114,32 @@ static int omap3_rom_rng_probe(struct platform_device *pdev)
return PTR_ERR(rng_clk);
}
+ ret = clk_prepare(rng_clk);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "clk_prepare failed: %i\n", ret);
+ return ret;
+ }
+
/* Leave the RNG in reset state. */
- ret = clk_prepare_enable(rng_clk);
+ ret = clk_enable(rng_clk);
if (ret)
- return ret;
+ goto err_unprepare;
omap3_rom_rng_idle(0);
return hwrng_register(&omap3_rom_rng_ops);
+
+err_unprepare:
+ clk_unprepare(rng_clk);
+
+ return ret;
}
static int omap3_rom_rng_remove(struct platform_device *pdev)
{
cancel_delayed_work_sync(&idle_work);
hwrng_unregister(&omap3_rom_rng_ops);
- clk_disable_unprepare(rng_clk);
+ clk_unprepare(rng_clk);
+
return 0;
}
--
2.23.0
Powered by blists - more mailing lists