dmaengine: fsl-edma: refactor chan_name setup and safety
authorFrank Li <Frank.Li@nxp.com>
Mon, 21 Aug 2023 16:16:14 +0000 (12:16 -0400)
committerVinod Koul <vkoul@kernel.org>
Tue, 22 Aug 2023 14:41:03 +0000 (20:11 +0530)
Relocated the setup of chan_name from setup_irq() to fsl_chan init. This
change anticipates its future use in various locations.

For increased safety, sprintf has been replaced with snprintf. In addition,
The size of the fsl_chan->name[] array was expanded from 16 to 32.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-10-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/fsl-edma-common.h
drivers/dma/fsl-edma-main.c

index 521b79f..316df42 100644 (file)
@@ -116,7 +116,7 @@ struct fsl_edma_chan {
        dma_addr_t                      dma_dev_addr;
        u32                             dma_dev_size;
        enum dma_data_direction         dma_dir;
-       char                            chan_name[16];
+       char                            chan_name[32];
 };
 
 struct fsl_edma_desc {
index 111cfa2..d68ea16 100644 (file)
@@ -175,8 +175,6 @@ fsl_edma2_irq_init(struct platform_device *pdev,
                if (irq < 0)
                        return -ENXIO;
 
-               sprintf(fsl_edma->chans[i].chan_name, "eDMA2-CH%02d", i);
-
                /* The last IRQ is for eDMA err */
                if (i == count - 1)
                        ret = devm_request_irq(&pdev->dev, irq,
@@ -313,6 +311,9 @@ static int fsl_edma_probe(struct platform_device *pdev)
        for (i = 0; i < fsl_edma->n_chans; i++) {
                struct fsl_edma_chan *fsl_chan = &fsl_edma->chans[i];
 
+               snprintf(fsl_chan->chan_name, sizeof(fsl_chan->chan_name), "%s-CH%02d",
+                                                          dev_name(&pdev->dev), i);
+
                fsl_chan->edma = fsl_edma;
                fsl_chan->pm_state = RUNNING;
                fsl_chan->slave_id = 0;