[PATCH 2/2] hwrng: cctrng - use device-managed api for runtime pm
From: Martin Kaiser
Date: Sat Nov 14 2026 - 12:04:54 EST
Use the device-managed api to enable runtime pm in the probe function.
The disable function is called from the devres layer when the device
is removed.
Disabling runtime pm was the only operation in the driver's remove
function. It can now be deleted.
Signed-off-by: Martin Kaiser <martin@xxxxxxxxx>
---
drivers/char/hw_random/cctrng.c | 33 ++-------------------------------
1 file changed, 2 insertions(+), 31 deletions(-)
diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c
index ef3ca6d8cc85..ac77c6afea5b 100644
--- a/drivers/char/hw_random/cctrng.c
+++ b/drivers/char/hw_random/cctrng.c
@@ -97,26 +97,10 @@ static int cc_trng_pm_init(struct cctrng_drvdata *drvdata)
/* must be before the enabling to avoid redundant suspending */
pm_runtime_set_autosuspend_delay(dev, CC_TRNG_SUSPEND_TIMEOUT);
pm_runtime_use_autosuspend(dev);
- /* set us as active - note we won't do PM ops until cc_trng_pm_go()! */
+ /* set us as active - note we won't do PM ops until devm_pm_runtime_enable()! */
return pm_runtime_set_active(dev);
}
-static void cc_trng_pm_go(struct cctrng_drvdata *drvdata)
-{
- struct device *dev = &(drvdata->pdev->dev);
-
- /* enable the PM module*/
- pm_runtime_enable(dev);
-}
-
-static void cc_trng_pm_fini(struct cctrng_drvdata *drvdata)
-{
- struct device *dev = &(drvdata->pdev->dev);
-
- pm_runtime_disable(dev);
-}
-
-
static inline int cc_trng_parse_sampling_ratio(struct cctrng_drvdata *drvdata)
{
struct device *dev = &(drvdata->pdev->dev);
@@ -534,25 +518,13 @@ static int cctrng_probe(struct platform_device *pdev)
cc_trng_hw_trigger(drvdata);
/* All set, we can allow auto-suspend */
- cc_trng_pm_go(drvdata);
+ devm_pm_runtime_enable(dev);
dev_info(dev, "ARM cctrng device initialized\n");
return 0;
}
-static void cctrng_remove(struct platform_device *pdev)
-{
- struct cctrng_drvdata *drvdata = platform_get_drvdata(pdev);
- struct device *dev = &pdev->dev;
-
- dev_dbg(dev, "Releasing cctrng resources...\n");
-
- cc_trng_pm_fini(drvdata);
-
- dev_info(dev, "ARM cctrng device terminated\n");
-}
-
static int __maybe_unused cctrng_suspend(struct device *dev)
{
struct cctrng_drvdata *drvdata = dev_get_drvdata(dev);
@@ -634,7 +606,6 @@ static struct platform_driver cctrng_driver = {
.pm = &cctrng_pm,
},
.probe = cctrng_probe,
- .remove = cctrng_remove,
};
module_platform_driver(cctrng_driver);
--
2.43.7