[PATCH v2 05/10] dmaengine: imx-sdma: cosmetic cleanup

Marco Felsch
2025-09-11T21:59:50Z

Make use of local struct device pointer to not dereference the
platform_device pointer everytime.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/dma/imx-sdma.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 44411c15029c9b09f307c4b9e3f7b1ab77fa5093..b0def2bde77fe53b0805bddc0c5d6116c9cefcbe 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -2266,7 +2266,8 @@ static struct dma_chan *sdma_xlate(struct of_phandle_args *dma_spec,

static int sdma_probe(struct platform_device *pdev)
{
- struct device_node *np = pdev->dev.of_node;
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
const char *fw_name;
int ret;
int irq;
@@ -2274,18 +2275,18 @@ static int sdma_probe(struct platform_device *pdev)
struct sdma_engine *sdma;
s32 *saddr_arr;

- ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+ ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (ret)
return ret;

- sdma = devm_kzalloc(&pdev->dev, sizeof(*sdma), GFP_KERNEL);
+ sdma = devm_kzalloc(dev, sizeof(*sdma), GFP_KERNEL);
if (!sdma)
return -ENOMEM;

spin_lock_init(&sdma->channel_0_lock);

- sdma->dev = &pdev->dev;
- sdma->drvdata = of_device_get_match_data(sdma->dev);
+ sdma->dev = dev;
+ sdma->drvdata = of_device_get_match_data(dev);

irq = platform_get_irq(pdev, 0);
if (irq < 0)
@@ -2295,11 +2296,11 @@ static int sdma_probe(struct platform_device *pdev)
if (IS_ERR(sdma->regs))
return PTR_ERR(sdma->regs);

- sdma->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+ sdma->clk_ipg = devm_clk_get(dev, "ipg");
if (IS_ERR(sdma->clk_ipg))
return PTR_ERR(sdma->clk_ipg);

- sdma->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
+ sdma->clk_ahb = devm_clk_get(dev, "ahb");
if (IS_ERR(sdma->clk_ahb))
return PTR_ERR(sdma->clk_ahb);

@@ -2311,8 +2312,8 @@ static int sdma_probe(struct platform_device *pdev)
if (ret)
goto err_clk;

- ret = devm_request_irq(&pdev->dev, irq, sdma_int_handler, 0,
- dev_name(&pdev->dev), sdma);
+ ret = devm_request_irq(dev, irq, sdma_int_handler, 0,
+ dev_name(dev), sdma);
if (ret)
goto err_irq;

@@ -2357,7 +2358,7 @@ static int sdma_probe(struct platform_device *pdev)

sdma->iram_pool = of_gen_pool_get(np, "iram", 0);
if (sdma->iram_pool)
- dev_info(&pdev->dev, "alloc bd from iram.\n");
+ dev_info(dev, "alloc bd from iram.\n");

ret = sdma_init(sdma);
if (ret)
@@ -2370,7 +2371,7 @@ static int sdma_probe(struct platform_device *pdev)
if (sdma->drvdata->script_addrs)
sdma_add_scripts(sdma, sdma->drvdata->script_addrs);

- sdma->dma_device.dev = &pdev->dev;
+ sdma->dma_device.dev = dev;

sdma->dma_device.device_alloc_chan_resources = sdma_alloc_chan_resources;
sdma->dma_device.device_free_chan_resources = sdma_free_chan_resources;
@@ -2393,13 +2394,13 @@ static int sdma_probe(struct platform_device *pdev)

ret = dma_async_device_register(&sdma->dma_device);
if (ret) {
- dev_err(&pdev->dev, "unable to register\n");
+ dev_err(dev, "unable to register\n");
goto err_init;
}

ret = of_dma_controller_register(np, sdma_xlate, sdma);
if (ret) {
- dev_err(&pdev->dev, "failed to register controller\n");
+ dev_err(dev, "failed to register controller\n");
goto err_register;
}

@@ -2411,11 +2412,11 @@ static int sdma_probe(struct platform_device *pdev)
ret = of_property_read_string(np, "fsl,sdma-ram-script-name",
&fw_name);
if (ret) {
- dev_warn(&pdev->dev, "failed to get firmware name\n");
+ dev_warn(dev, "failed to get firmware name\n");
} else {
ret = sdma_get_firmware(sdma, fw_name);
if (ret)
- dev_warn(&pdev->dev, "failed to get firmware from device tree\n");
+ dev_warn(dev, "failed to get firmware from device tree\n");
}

return 0;

--
2.47.3