[PATCH 3/6] hwrng: omap3-rom - Call clk_prepare() on init and exit only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
Cc: Adam Ford <aford173@xxxxxxxxx>
Cc: Pali Rohár <pali.rohar@xxxxxxxxx>
Cc: Tero Kristo <t-kristo@xxxxxx>
Fixes: 1c6b7c2108bd ("hwrng: OMAP3 ROM Random Number Generator support")
Signed-off-by: Tony Lindgren <tony@xxxxxxxxxxx>
---
 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



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux