All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-crypto@vger.kernel.org
Cc: "Boris Brezillon" <bbrezillon@kernel.org>,
	"Arnaud Ebalard" <arno@natisbad.org>,
	"Srujana Challa" <schalla@marvell.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	"Rosen Penev" <rosenp@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 2/5] crypto: cesa: use enabled variants for clk_get
Date: Tue,  1 Oct 2024 16:25:44 -0700	[thread overview]
Message-ID: <20241001232547.355947-3-rosenp@gmail.com> (raw)
In-Reply-To: <20241001232547.355947-1-rosenp@gmail.com>

Avoids manual frees. Also simplifiies the code with _optional

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/crypto/marvell/cesa/cesa.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/crypto/marvell/cesa/cesa.c b/drivers/crypto/marvell/cesa/cesa.c
index 5fd31ba715c2..1c90e65c89d8 100644
--- a/drivers/crypto/marvell/cesa/cesa.c
+++ b/drivers/crypto/marvell/cesa/cesa.c
@@ -510,24 +510,16 @@ static int mv_cesa_probe(struct platform_device *pdev)
 		 * if the clock does not exist.
 		 */
 		snprintf(res_name, sizeof(res_name), "cesa%u", i);
-		engine->clk = devm_clk_get(dev, res_name);
+		engine->clk = devm_clk_get_optional_enabled(dev, res_name);
 		if (IS_ERR(engine->clk)) {
-			engine->clk = devm_clk_get(dev, NULL);
+			engine->clk = devm_clk_get_optional_enabled(dev, NULL);
 			if (IS_ERR(engine->clk))
-				engine->clk = NULL;
+				goto err_cleanup;
 		}
 
 		snprintf(res_name, sizeof(res_name), "cesaz%u", i);
-		engine->zclk = devm_clk_get(dev, res_name);
+		engine->zclk = devm_clk_get_optional_enabled(dev, res_name);
 		if (IS_ERR(engine->zclk))
-			engine->zclk = NULL;
-
-		ret = clk_prepare_enable(engine->clk);
-		if (ret)
-			goto err_cleanup;
-
-		ret = clk_prepare_enable(engine->zclk);
-		if (ret)
 			goto err_cleanup;
 
 		engine->regs = cesa->regs + CESA_ENGINE_OFF(i);
@@ -571,8 +563,6 @@ static int mv_cesa_probe(struct platform_device *pdev)
 
 err_cleanup:
 	for (i = 0; i < caps->nengines; i++) {
-		clk_disable_unprepare(cesa->engines[i].zclk);
-		clk_disable_unprepare(cesa->engines[i].clk);
 		mv_cesa_put_sram(pdev, i);
 		if (cesa->engines[i].irq > 0)
 			irq_set_affinity_hint(cesa->engines[i].irq, NULL);
@@ -589,8 +579,6 @@ static void mv_cesa_remove(struct platform_device *pdev)
 	mv_cesa_remove_algs(cesa);
 
 	for (i = 0; i < cesa->caps->nengines; i++) {
-		clk_disable_unprepare(cesa->engines[i].zclk);
-		clk_disable_unprepare(cesa->engines[i].clk);
 		mv_cesa_put_sram(pdev, i);
 		irq_set_affinity_hint(cesa->engines[i].irq, NULL);
 	}
-- 
2.46.2


  parent reply	other threads:[~2024-10-01 23:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-01 23:25 [PATCH 0/5] cesa: small cleanups Rosen Penev
2024-10-01 23:25 ` [PATCH 1/5] crypto: cesa: add COMPILE_TEST Rosen Penev
2024-10-01 23:25 ` Rosen Penev [this message]
2024-10-03 11:27   ` [PATCH 2/5] crypto: cesa: use enabled variants for clk_get Dan Carpenter
2024-10-01 23:25 ` [PATCH 3/5] crypto: cesa: remove irq_set_affinity_hint Rosen Penev
2024-10-01 23:25 ` [PATCH 4/5] crypto: cesa: move loop to mv_cesa_put_sram Rosen Penev
2024-10-01 23:25 ` [PATCH 5/5] crypto: use devm_platform_get_and_ioremap_resource Rosen Penev
  -- strict thread matches above, loose matches on Subject: below --
2024-10-03 11:03 [PATCH 2/5] crypto: cesa: use enabled variants for clk_get kernel test robot

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=20241001232547.355947-3-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=arno@natisbad.org \
    --cc=bbrezillon@kernel.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schalla@marvell.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.