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: aric.pzqi@ingenic.com, linux-crypto@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Martin Kaiser <martin@kaiser.cx>
Subject: [PATCH 4/7] hwrng: ingenic - use devm_clk_get_enabled
Date: Mon, 10 Jul 2023 22:27:30 +0200	[thread overview]
Message-ID: <20230710202733.116133-5-martin@kaiser.cx> (raw)
In-Reply-To: <20230710202733.116133-1-martin@kaiser.cx>

Use devm_clk_get_enabled in the ingenic-trng driver. We don't have to
disable and unprepare the clock any more in error paths or in the remove
function.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/char/hw_random/ingenic-trng.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/char/hw_random/ingenic-trng.c b/drivers/char/hw_random/ingenic-trng.c
index bfec28ceab00..906fa78de47e 100644
--- a/drivers/char/hw_random/ingenic-trng.c
+++ b/drivers/char/hw_random/ingenic-trng.c
@@ -29,7 +29,6 @@
 
 struct ingenic_trng {
 	void __iomem *base;
-	struct clk *clk;
 	struct hwrng rng;
 };
 
@@ -77,6 +76,7 @@ static int ingenic_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait
 static int ingenic_trng_probe(struct platform_device *pdev)
 {
 	struct ingenic_trng *trng;
+	struct clk *clk;
 	int ret;
 
 	trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
@@ -89,16 +89,10 @@ static int ingenic_trng_probe(struct platform_device *pdev)
 		return PTR_ERR(trng->base);
 	}
 
-	trng->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(trng->clk)) {
-		pr_crit("%s: Cannot get DTRNG clock\n", __func__);
-		return PTR_ERR(trng->clk);
-	}
-
-	ret = clk_prepare_enable(trng->clk);
-	if (ret) {
-		pr_crit("%s: Unable to enable DTRNG clock\n", __func__);
-		return ret;
+	clk = devm_clk_get_enabled(&pdev->dev, NULL);
+	if (IS_ERR(clk)) {
+		pr_crit("%s: Cannot get and enable DTRNG clock\n", __func__);
+		return PTR_ERR(clk);
 	}
 
 	trng->rng.name = pdev->name;
@@ -109,17 +103,13 @@ static int ingenic_trng_probe(struct platform_device *pdev)
 	ret = hwrng_register(&trng->rng);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register hwrng\n");
-		goto err_unprepare_clk;
+		return ret;
 	}
 
 	platform_set_drvdata(pdev, trng);
 
 	dev_info(&pdev->dev, "Ingenic DTRNG driver registered\n");
 	return 0;
-
-err_unprepare_clk:
-	clk_disable_unprepare(trng->clk);
-	return ret;
 }
 
 static int ingenic_trng_remove(struct platform_device *pdev)
@@ -133,8 +123,6 @@ static int ingenic_trng_remove(struct platform_device *pdev)
 	ctrl &= ~CFG_GEN_EN;
 	writel(ctrl, trng->base + TRNG_REG_CFG_OFFSET);
 
-	clk_disable_unprepare(trng->clk);
-
 	return 0;
 }
 
-- 
2.30.2


  parent reply	other threads:[~2023-07-10 20:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-10 20:27 hwrng: ingenic: simplify the code Martin Kaiser
2023-07-10 20:27 ` [PATCH 1/7] hwrng: ingenic - enable compile testing Martin Kaiser
2023-07-10 20:27 ` [PATCH 2/7] hwrng: ingenic - remove two unused defines Martin Kaiser
2023-07-10 20:27 ` [PATCH 3/7] hwrng: ingenic - remove dead assignments Martin Kaiser
2023-07-10 20:27 ` Martin Kaiser [this message]
2023-07-10 20:27 ` [PATCH 5/7] hwrng: ingenic - use dev_err_probe in error paths Martin Kaiser
2023-07-10 20:27 ` [PATCH 6/7] hwrng: ingenic - don't disable the rng in ingenic_trng_remove Martin Kaiser
2023-07-10 20:27 ` [PATCH 7/7] hwrng: ingenic - switch to device managed registration Martin Kaiser
2023-07-22  2:13 ` hwrng: ingenic: simplify the code 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=20230710202733.116133-5-martin@kaiser.cx \
    --to=martin@kaiser.cx \
    --cc=aric.pzqi@ingenic.com \
    --cc=herbert@gondor.apana.org.au \
    --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®