diff mbox series

hwrng: mtk - Add remove function

Message ID 20240826014419.5151-1-guoqing.jiang@canonical.com
State New
Headers show
Series hwrng: mtk - Add remove function | expand

Commit Message

Guoqing Jiang Aug. 26, 2024, 1:44 a.m. UTC
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@canonical.com>
---
 drivers/char/hw_random/mtk-rng.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

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);
+	pm_runtime_set_suspended(&pdev->dev);
+	devm_hwrng_unregister(&pdev->dev, &priv->rng);
+}
+
 #ifdef CONFIG_PM
 static int mtk_rng_runtime_suspend(struct device *dev)
 {
@@ -186,6 +195,7 @@  MODULE_DEVICE_TABLE(of, mtk_rng_match);
 
 static struct platform_driver mtk_rng_driver = {
 	.probe          = mtk_rng_probe,
+	.remove_new	= mtk_rng_remove,
 	.driver = {
 		.name = MTK_RNG_DEV,
 		.pm = MTK_RNG_PM_OPS,