diff mbox series

[PATCHv2,4/5] crypto: cesa: move loop to mv_cesa_put_sram

Message ID 20241010194517.18635-5-rosenp@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show
Series cesa: small cleanups | expand

Commit Message

Rosen Penev Oct. 10, 2024, 7:45 p.m. UTC
Simpler to move it there. More readable remove.

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

Comments

Herbert Xu Oct. 18, 2024, 9:11 a.m. UTC | #1
On Thu, Oct 10, 2024 at 12:45:16PM -0700, Rosen Penev wrote:
>
> @@ -566,21 +572,16 @@ static int mv_cesa_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_cleanup:
> -	for (i = 0; i < caps->nengines; i++)
> -		mv_cesa_put_sram(pdev, i);
> -
> +	mv_cesa_put_sram(pdev);

I think it'd be cleaner if you introduced a new function that
did the loop and kept mv_cesa_put_sram as is.

Thanks,
diff mbox series

Patch

diff --git a/drivers/crypto/marvell/cesa/cesa.c b/drivers/crypto/marvell/cesa/cesa.c
index 21e13f4a1f48..a65f328b7094 100644
--- a/drivers/crypto/marvell/cesa/cesa.c
+++ b/drivers/crypto/marvell/cesa/cesa.c
@@ -416,17 +416,23 @@  static int mv_cesa_get_sram(struct platform_device *pdev, int idx)
 	return 0;
 }
 
-static void mv_cesa_put_sram(struct platform_device *pdev, int idx)
+static void mv_cesa_put_sram(struct platform_device *pdev)
 {
 	struct mv_cesa_dev *cesa = platform_get_drvdata(pdev);
-	struct mv_cesa_engine *engine = &cesa->engines[idx];
+	const struct mv_cesa_caps *caps = &orion_caps;
+	int i;
 
-	if (engine->pool)
-		gen_pool_free(engine->pool, (unsigned long)engine->sram_pool,
-			      cesa->sram_size);
-	else
-		dma_unmap_resource(cesa->dev, engine->sram_dma,
-				   cesa->sram_size, DMA_BIDIRECTIONAL, 0);
+	for (i = 0; i < caps->nengines; i++) {
+		struct mv_cesa_engine *engine = &cesa->engines[i];
+		if (engine->pool)
+			gen_pool_free(engine->pool,
+				      (unsigned long)engine->sram_pool,
+				      cesa->sram_size);
+		else
+			dma_unmap_resource(cesa->dev, engine->sram_dma,
+					   cesa->sram_size, DMA_BIDIRECTIONAL,
+					   0);
+	}
 }
 
 static int mv_cesa_probe(struct platform_device *pdev)
@@ -566,21 +572,16 @@  static int mv_cesa_probe(struct platform_device *pdev)
 	return 0;
 
 err_cleanup:
-	for (i = 0; i < caps->nengines; i++)
-		mv_cesa_put_sram(pdev, i);
-
+	mv_cesa_put_sram(pdev);
 	return ret;
 }
 
 static void mv_cesa_remove(struct platform_device *pdev)
 {
 	struct mv_cesa_dev *cesa = platform_get_drvdata(pdev);
-	int i;
 
 	mv_cesa_remove_algs(cesa);
-
-	for (i = 0; i < cesa->caps->nengines; i++)
-		mv_cesa_put_sram(pdev, i);
+	mv_cesa_put_sram(pdev);
 }
 
 static const struct platform_device_id mv_cesa_plat_id_table[] = {