Skip to content

Commit 9b05554

Browse files
nxpfranklivinodkoul
authored andcommitted
dmaengine: fsl-edma: refactor chan_name setup and safety
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>
1 parent f5b3ba5 commit 9b05554

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

drivers/dma/fsl-edma-common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct fsl_edma_chan {
116116
dma_addr_t dma_dev_addr;
117117
u32 dma_dev_size;
118118
enum dma_data_direction dma_dir;
119-
char chan_name[16];
119+
char chan_name[32];
120120
};
121121

122122
struct fsl_edma_desc {

drivers/dma/fsl-edma-main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ fsl_edma2_irq_init(struct platform_device *pdev,
175175
if (irq < 0)
176176
return -ENXIO;
177177

178-
sprintf(fsl_edma->chans[i].chan_name, "eDMA2-CH%02d", i);
179-
180178
/* The last IRQ is for eDMA err */
181179
if (i == count - 1)
182180
ret = devm_request_irq(&pdev->dev, irq,
@@ -313,6 +311,9 @@ static int fsl_edma_probe(struct platform_device *pdev)
313311
for (i = 0; i < fsl_edma->n_chans; i++) {
314312
struct fsl_edma_chan *fsl_chan = &fsl_edma->chans[i];
315313

314+
snprintf(fsl_chan->chan_name, sizeof(fsl_chan->chan_name), "%s-CH%02d",
315+
dev_name(&pdev->dev), i);
316+
316317
fsl_chan->edma = fsl_edma;
317318
fsl_chan->pm_state = RUNNING;
318319
fsl_chan->slave_id = 0;

0 commit comments

Comments
 (0)