[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250911-v6-16-topic-sdma-v2-6-d315f56343b5@pengutronix.de>
Date: Thu, 11 Sep 2025 23:56:47 +0200
From: Marco Felsch <m.felsch@...gutronix.de>
To: Vinod Koul <vkoul@...nel.org>, Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, Jiada Wang <jiada_wang@...tor.com>
Cc: dmaengine@...r.kernel.org, imx@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Marco Felsch <m.felsch@...gutronix.de>, Frank Li <Frank.Li@....com>
Subject: [PATCH v2 06/10] dmaengine: imx-sdma: make use of devm_kzalloc for
script_addrs
Shuffle the allocation of script_addrs and make use of devm_kzalloc() to
drop the local error handling as well as the kfree() during the remove.
Reviewed-by: Frank Li <Frank.Li@....com>
Signed-off-by: Marco Felsch <m.felsch@...gutronix.de>
---
drivers/dma/imx-sdma.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index b0def2bde77fe53b0805bddc0c5d6116c9cefcbe..d6239900ba12063bdb7d807db1bdbdc2b446a94c 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -2283,6 +2283,10 @@ static int sdma_probe(struct platform_device *pdev)
if (!sdma)
return -ENOMEM;
+ sdma->script_addrs = devm_kzalloc(dev, sizeof(*sdma->script_addrs), GFP_KERNEL);
+ if (!sdma->script_addrs)
+ return -ENOMEM;
+
spin_lock_init(&sdma->channel_0_lock);
sdma->dev = dev;
@@ -2319,12 +2323,6 @@ static int sdma_probe(struct platform_device *pdev)
sdma->irq = irq;
- sdma->script_addrs = kzalloc(sizeof(*sdma->script_addrs), GFP_KERNEL);
- if (!sdma->script_addrs) {
- ret = -ENOMEM;
- goto err_irq;
- }
-
/* initially no scripts available */
saddr_arr = (s32 *)sdma->script_addrs;
for (i = 0; i < sizeof(*sdma->script_addrs) / sizeof(s32); i++)
@@ -2362,11 +2360,11 @@ static int sdma_probe(struct platform_device *pdev)
ret = sdma_init(sdma);
if (ret)
- goto err_init;
+ goto err_irq;
ret = sdma_event_remap(sdma);
if (ret)
- goto err_init;
+ goto err_irq;
if (sdma->drvdata->script_addrs)
sdma_add_scripts(sdma, sdma->drvdata->script_addrs);
@@ -2395,7 +2393,7 @@ static int sdma_probe(struct platform_device *pdev)
ret = dma_async_device_register(&sdma->dma_device);
if (ret) {
dev_err(dev, "unable to register\n");
- goto err_init;
+ goto err_irq;
}
ret = of_dma_controller_register(np, sdma_xlate, sdma);
@@ -2423,8 +2421,6 @@ static int sdma_probe(struct platform_device *pdev)
err_register:
dma_async_device_unregister(&sdma->dma_device);
-err_init:
- kfree(sdma->script_addrs);
err_irq:
clk_unprepare(sdma->clk_ahb);
err_clk:
@@ -2440,7 +2436,6 @@ static void sdma_remove(struct platform_device *pdev)
of_dma_controller_free(sdma->dev->of_node);
devm_free_irq(&pdev->dev, sdma->irq, sdma);
dma_async_device_unregister(&sdma->dma_device);
- kfree(sdma->script_addrs);
clk_unprepare(sdma->clk_ahb);
clk_unprepare(sdma->clk_ipg);
/* Kill the tasklet */
--
2.47.3
Powered by blists - more mailing lists