summaryrefslogtreecommitdiff
path: root/drivers/dma
diff options
context:
space:
mode:
authorAmelie Delaunay <amelie.delaunay@foss.st.com>2024-05-31 18:07:11 +0300
committerVinod Koul <vkoul@kernel.org>2024-06-11 21:25:34 +0300
commit49b1c21ff815168eca44e81ab0612b1f00759efb (patch)
tree96188aa7108f71835c7c2506dbe3af119e4cbb99 /drivers/dma
parent10b8e0fd3f7234a38db2c8d2c8dec0bd6eeede44 (diff)
downloadlinux-49b1c21ff815168eca44e81ab0612b1f00759efb.tar.xz
dmaengine: stm32-dma3: defer channel registration to specify channel name
On STM32 DMA3, channels can be reserved, so they are non available for Linux. This non-availability creates a mismatch between dma_chan id and DMA3 channel id. Use dma_async_device_channel_register() to register the channels after controller registration and change the default channel name, so that it can match the name in the Reference Manual and ease requesting a channel thanks to its name. Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com> Link: https://lore.kernel.org/r/20240531150712.2503554-12-amelie.delaunay@foss.st.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/stm32/stm32-dma3.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/dma/stm32/stm32-dma3.c b/drivers/dma/stm32/stm32-dma3.c
index 66d5129f4822..4087e0263a48 100644
--- a/drivers/dma/stm32/stm32-dma3.c
+++ b/drivers/dma/stm32/stm32-dma3.c
@@ -1732,9 +1732,6 @@ static int stm32_dma3_probe(struct platform_device *pdev)
chan->fifo_size = get_chan_hwcfg(i, G_FIFO_SIZE(i), hwcfgr);
/* If chan->fifo_size > 0 then half of the fifo size, else no burst when no FIFO */
chan->max_burst = (chan->fifo_size) ? (1 << (chan->fifo_size + 1)) / 2 : 0;
- chan->vchan.desc_free = stm32_dma3_chan_vdesc_free;
-
- vchan_init(&chan->vchan, dma_dev);
}
ret = dmaenginem_async_device_register(dma_dev);
@@ -1742,14 +1739,26 @@ static int stm32_dma3_probe(struct platform_device *pdev)
goto err_clk_disable;
for (i = 0; i < ddata->dma_channels; i++) {
+ char name[12];
+
if (chan_reserved & BIT(i))
continue;
+ chan = &ddata->chans[i];
+ snprintf(name, sizeof(name), "dma%dchan%d", ddata->dma_dev.dev_id, chan->id);
+
+ chan->vchan.desc_free = stm32_dma3_chan_vdesc_free;
+ vchan_init(&chan->vchan, dma_dev);
+
+ ret = dma_async_device_channel_register(&ddata->dma_dev, &chan->vchan.chan, name);
+ if (ret) {
+ dev_err_probe(&pdev->dev, ret, "Failed to register channel %s\n", name);
+ goto err_clk_disable;
+ }
+
ret = platform_get_irq(pdev, i);
if (ret < 0)
goto err_clk_disable;
-
- chan = &ddata->chans[i];
chan->irq = ret;
ret = devm_request_irq(&pdev->dev, chan->irq, stm32_dma3_chan_irq, 0,