Re: [PATCH] hwrng: mtk - Add remove function

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

 





On 8/26/24 13:17, Chen-Yu Tsai wrote:
On Mon, Aug 26, 2024 at 9:45 AM Guoqing Jiang
<guoqing.jiang@xxxxxxxxxxxxx> wrote:
Add mtk_rng_remove function which calles pm_runtime relevant funcs
and unregister hwrng to paired with mtk_rng_probe.

And without remove function, pm_runtime complains below when reload
the driver.

mtk_rng 1020f000.rng: Unbalanced pm_runtime_enable!

Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxx>
---
  drivers/char/hw_random/mtk-rng.c | 10 ++++++++++
  1 file changed, 10 insertions(+)

diff --git a/drivers/char/hw_random/mtk-rng.c b/drivers/char/hw_random/mtk-rng.c
index 302e201b51c2..1b6aa9406b11 100644
--- a/drivers/char/hw_random/mtk-rng.c
+++ b/drivers/char/hw_random/mtk-rng.c
@@ -149,6 +149,15 @@ static int mtk_rng_probe(struct platform_device *pdev)
         return 0;
  }

+static void mtk_rng_remove(struct platform_device *pdev)
+{
+        struct mtk_rng *priv = platform_get_drvdata(pdev);
+
+       pm_runtime_disable(&pdev->dev);
Instead maybe just replace pm_runtime_enable() with devm_pm_runtime_enable()
in the probe function?

Good point, will try it though it seems the function was not called by any hwrng driver so far.

+       pm_runtime_set_suspended(&pdev->dev);
Not sure if this is needed? I'm not super familiar with runtime PM.

+       devm_hwrng_unregister(&pdev->dev, &priv->rng);
The fact that it is already devm_* means that you shouldn't need to
call it.

Okay, will remove the unnecessary calls.

Thanks,
Guoqing






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