mirror of https://lore.kernel.org/lkml/
 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 1/2] hwrng: cctrng - simplify runtime pm refcount code
Date: Sat, 14 Nov 2026 18:03:14 +0100	[thread overview]
Message-ID: <20261114170335.1680546-2-martin@kaiser.cx> (raw)
In-Reply-To: <20261114170335.1680546-1-martin@kaiser.cx>

Clean up the code for runtime pm refcounts.

The cc_trng_pm_get helper function isn't really useful, call
pm_runtime_resume_and_get directly.

In dev_err_probe, show the error code only once.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/char/hw_random/cctrng.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c
index b5f2c75d2eb8..ef3ca6d8cc85 100644
--- a/drivers/char/hw_random/cctrng.c
+++ b/drivers/char/hw_random/cctrng.c
@@ -85,12 +85,6 @@ static inline u32 cc_ioread(struct cctrng_drvdata *drvdata, u32 reg)
 	return ioread32(drvdata->cc_base + reg);
 }
 
-
-static int cc_trng_pm_get(struct device *dev)
-{
-	return pm_runtime_resume_and_get(dev);
-}
-
 static void cc_trng_pm_put_suspend(struct device *dev)
 {
 	pm_runtime_put_autosuspend(dev);
@@ -239,11 +233,11 @@ static int cctrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
 			/* re-check space in buffer to avoid potential race */
 			if (circ_buf_space(drvdata) >= CC_TRNG_EHR_IN_WORDS) {
 				/* increment device's usage counter */
-				int rc = cc_trng_pm_get(dev);
+				int rc = pm_runtime_resume_and_get(dev);
 
 				if (rc) {
 					dev_err(dev,
-						"cc_trng_pm_get returned %x\n",
+						"pm_runtime_resume_and_get returned %x\n",
 						rc);
 					return rc;
 				}
@@ -521,9 +515,9 @@ static int cctrng_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, rc, "cc_trng_pm_init failed\n");
 
 	/* increment device's usage counter */
-	rc = cc_trng_pm_get(dev);
+	rc = pm_runtime_resume_and_get(dev);
 	if (rc)
-		return dev_err_probe(dev, rc, "cc_trng_pm_get returned %x\n", rc);
+		return dev_err_probe(dev, rc, "pm_runtime_resume_and_get failed\n");
 
 	/* set pending_hw to verify that HW won't be triggered from read */
 	atomic_set(&drvdata->pending_hw, 1);
-- 
2.43.7


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

Thread overview: 3+ 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 ` Martin Kaiser [this message]
2026-11-14 17:03 ` [PATCH 2/2] hwrng: cctrng - use device-managed api for " Martin Kaiser

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-2-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

all inboxes | Powered by JetHome®