[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241001232547.355947-3-rosenp@gmail.com>
Date: Tue, 1 Oct 2024 16:25:44 -0700
From: Rosen Penev <rosenp@...il.com>
To: linux-crypto@...r.kernel.org
Cc: Boris Brezillon <bbrezillon@...nel.org>,
Arnaud Ebalard <arno@...isbad.org>,
Srujana Challa <schalla@...vell.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
Rosen Penev <rosenp@...il.com>,
Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH 2/5] crypto: cesa: use enabled variants for clk_get
Avoids manual frees. Also simplifiies the code with _optional
Signed-off-by: Rosen Penev <rosenp@...il.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
Powered by blists - more mailing lists