mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sam Protsenko <semen.protsenko@linaro.org>
To: "Łukasz Stelmach" <l.stelmach@samsung.com>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>
Cc: Anand Moon <linux.amoon@gmail.com>,
	Olivia Mackall <olivia@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	linux-samsung-soc@vger.kernel.org, linux-crypto@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/7] hwrng: exynos: Use devm_clk_get_enabled() to get the clock
Date: Tue, 18 Jun 2024 15:45:19 -0500	[thread overview]
Message-ID: <20240618204523.9563-4-semen.protsenko@linaro.org> (raw)
In-Reply-To: <20240618204523.9563-1-semen.protsenko@linaro.org>

Use devm_clk_get_enabled() helper instead of calling devm_clk_get() and
then clk_prepare_enable(). It simplifies the error handling and makes
the code more compact. Also use dev_err_probe() to handle possible
-EPROBE_DEFER errors if the clock is not available yet.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v2:
  - No changes (it's a new patch added in v2)

 drivers/char/hw_random/exynos-trng.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
index 88a5088ed34d..91c210d80a3d 100644
--- a/drivers/char/hw_random/exynos-trng.c
+++ b/drivers/char/hw_random/exynos-trng.c
@@ -134,32 +134,23 @@ static int exynos_trng_probe(struct platform_device *pdev)
 		goto err_pm_get;
 	}
 
-	trng->clk = devm_clk_get(&pdev->dev, "secss");
+	trng->clk = devm_clk_get_enabled(&pdev->dev, "secss");
 	if (IS_ERR(trng->clk)) {
-		ret = PTR_ERR(trng->clk);
-		dev_err(&pdev->dev, "Could not get clock.\n");
-		goto err_clock;
-	}
-
-	ret = clk_prepare_enable(trng->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "Could not enable the clk.\n");
+		ret = dev_err_probe(&pdev->dev, PTR_ERR(trng->clk),
+				    "Could not get clock");
 		goto err_clock;
 	}
 
 	ret = devm_hwrng_register(&pdev->dev, &trng->rng);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not register hwrng device.\n");
-		goto err_register;
+		goto err_clock;
 	}
 
 	dev_info(&pdev->dev, "Exynos True Random Number Generator.\n");
 
 	return 0;
 
-err_register:
-	clk_disable_unprepare(trng->clk);
-
 err_clock:
 	pm_runtime_put_noidle(&pdev->dev);
 
@@ -171,10 +162,6 @@ static int exynos_trng_probe(struct platform_device *pdev)
 
 static void exynos_trng_remove(struct platform_device *pdev)
 {
-	struct exynos_trng_dev *trng = platform_get_drvdata(pdev);
-
-	clk_disable_unprepare(trng->clk);
-
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 }
-- 
2.39.2


  parent reply	other threads:[~2024-06-18 20:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18 20:45 [PATCH v2 0/7] hwrng: exynos: Add support for Exynos850 Sam Protsenko
2024-06-18 20:45 ` [PATCH v2 1/7] dt-bindings: rng: Add Exynos850 support to exynos-trng Sam Protsenko
2024-06-20  7:27   ` Krzysztof Kozlowski
2024-06-18 20:45 ` [PATCH v2 2/7] hwrng: exynos: Improve coding style Sam Protsenko
     [not found]   ` <CGME20240620085239eucas1p1d49a6bae77e1fc857e4459f87c619a83@eucas1p1.samsung.com>
2024-06-20  8:52     ` Lukasz Stelmach
2024-06-18 20:45 ` Sam Protsenko [this message]
2024-06-20  7:29   ` [PATCH v2 3/7] hwrng: exynos: Use devm_clk_get_enabled() to get the clock Krzysztof Kozlowski
2024-06-20  9:27   ` Anand Moon
2024-06-18 20:45 ` [PATCH v2 4/7] hwrng: exynos: Implement bus clock control Sam Protsenko
2024-06-20  7:29   ` Krzysztof Kozlowski
2024-06-20  9:27   ` Anand Moon
2024-06-18 20:45 ` [PATCH v2 5/7] hwrng: exynos: Add SMC based TRNG operation Sam Protsenko
     [not found]   ` <CGME20240620134610eucas1p2fbcd7218bc220bf568ea117acf2f4781@eucas1p2.samsung.com>
2024-06-20 13:46     ` Lukasz Stelmach
2024-06-20 21:39       ` Sam Protsenko
2024-06-18 20:45 ` [PATCH v2 6/7] hwrng: exynos: Enable Exynos850 support Sam Protsenko
2024-06-20  7:29   ` Krzysztof Kozlowski
     [not found]   ` <CGME20240620084749eucas1p18f46cc9aa0983afb75e1677b399d12f8@eucas1p1.samsung.com>
2024-06-20  8:47     ` Lukasz Stelmach
2024-06-18 20:45 ` [PATCH v2 7/7] arm64: dts: exynos850: Enable TRNG Sam Protsenko
2024-06-20  7:31   ` Krzysztof Kozlowski
2024-06-20 21:51     ` Sam Protsenko
2024-07-01 12:27   ` (subset) " Krzysztof Kozlowski

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=20240618204523.9563-4-semen.protsenko@linaro.org \
    --to=semen.protsenko@linaro.org \
    --cc=alim.akhtar@samsung.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=krzk+dt@kernel.org \
    --cc=l.stelmach@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux.amoon@gmail.com \
    --cc=olivia@selenic.com \
    --cc=robh@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®