From: Martin Kaiser <martin@kaiser.cx>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Joshua Henderson <joshua.henderson@microchip.com>,
linux-crypto@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Martin Kaiser <martin@kaiser.cx>
Subject: [PATCH 2/4] hwrng: pic32 - use devm_clk_get_enabled
Date: Tue, 4 Jul 2023 19:32:01 +0200 [thread overview]
Message-ID: <20230704173203.70706-3-martin@kaiser.cx> (raw)
In-Reply-To: <20230704173203.70706-1-martin@kaiser.cx>
Use devm_clk_get_enabled in the pic32 driver. Ensure that the clock is
enabled as long as the driver is registered with the hwrng core.
Fixes: 7ea39973d1e5 ("hwrng: pic32 - Use device-managed registration API")
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/char/hw_random/pic32-rng.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/drivers/char/hw_random/pic32-rng.c b/drivers/char/hw_random/pic32-rng.c
index 99c8bd0859a1..e04a054e8930 100644
--- a/drivers/char/hw_random/pic32-rng.c
+++ b/drivers/char/hw_random/pic32-rng.c
@@ -36,7 +36,6 @@
struct pic32_rng {
void __iomem *base;
struct hwrng rng;
- struct clk *clk;
};
/*
@@ -70,6 +69,7 @@ static int pic32_rng_read(struct hwrng *rng, void *buf, size_t max,
static int pic32_rng_probe(struct platform_device *pdev)
{
struct pic32_rng *priv;
+ struct clk *clk;
u32 v;
int ret;
@@ -81,13 +81,9 @@ static int pic32_rng_probe(struct platform_device *pdev)
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
- priv->clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(priv->clk))
- return PTR_ERR(priv->clk);
-
- ret = clk_prepare_enable(priv->clk);
- if (ret)
- return ret;
+ clk = devm_clk_get_enabled(&pdev->dev, NULL);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
/* enable TRNG in enhanced mode */
v = TRNGEN | TRNGMOD;
@@ -98,15 +94,11 @@ static int pic32_rng_probe(struct platform_device *pdev)
ret = devm_hwrng_register(&pdev->dev, &priv->rng);
if (ret)
- goto err_register;
+ return ret;
platform_set_drvdata(pdev, priv);
return 0;
-
-err_register:
- clk_disable_unprepare(priv->clk);
- return ret;
}
static int pic32_rng_remove(struct platform_device *pdev)
@@ -114,7 +106,6 @@ static int pic32_rng_remove(struct platform_device *pdev)
struct pic32_rng *rng = platform_get_drvdata(pdev);
writel(0, rng->base + RNGCON);
- clk_disable_unprepare(rng->clk);
return 0;
}
--
2.30.2
next prev parent reply other threads:[~2023-07-04 17:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-04 17:31 [PATCH 0/4] hwrng: pic32 - some simple cleanups Martin Kaiser
2023-07-04 17:32 ` [PATCH 1/4] hwrng: pic32 - enable compile-testing Martin Kaiser
2023-07-04 17:32 ` Martin Kaiser [this message]
2023-07-04 17:32 ` [PATCH 3/4] hwrng: pic32 - remove unused defines Martin Kaiser
2023-07-04 17:32 ` [PATCH 4/4] hwrng: pic32 - enable TRNG only while it's used Martin Kaiser
2023-07-14 8:58 ` [PATCH 0/4] hwrng: pic32 - some simple cleanups Herbert Xu
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=20230704173203.70706-3-martin@kaiser.cx \
--to=martin@kaiser.cx \
--cc=herbert@gondor.apana.org.au \
--cc=joshua.henderson@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--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®