Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Martin Kaiser <martin@kaiser.cx>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	Martin Kaiser <martin@kaiser.cx>
Subject: [PATCH 2/2] hwrng: cctrng - use device-managed api for runtime pm
Date: Sat, 14 Nov 2026 18:03:15 +0100	[thread overview]
Message-ID: <20261114170335.1680546-3-martin@kaiser.cx> (raw)
In-Reply-To: <20261114170335.1680546-1-martin@kaiser.cx>

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@kaiser.cx>
---
 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


  parent reply	other threads:[~2026-11-14 17:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 17:03 [PATCH 0/2] hwrng: cctrng - simplify runtime pm Martin Kaiser
2026-11-14 17:03 ` [PATCH 1/2] hwrng: cctrng - simplify runtime pm refcount code Martin Kaiser
2026-11-14 17:03 ` Martin Kaiser [this message]
2026-11-14 17:21   ` [PATCH 2/2] hwrng: cctrng - use device-managed api for runtime pm sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261114170335.1680546-3-martin@kaiser.cx \
    --to=martin@kaiser.cx \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox