Skip to content

Commit 1cb30cb

Browse files
committed
serial: stm32: use dma_request/release_chan_linked API for rx
A new API has been created in dmaengine to automatically create device link between DMA and DMA clients. Move to this new API to avoid suspend/resume ordering issues. Change-Id: Ib70e4cad2cfb00f3d72cb972d9563e8b574a91f8 Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/155328 Reviewed-by: CITOOLS <smet-aci-reviews@lists.codex.cro.st.com> Reviewed-by: Erwan LE RAY <erwan.leray@st.com> Reviewed-by: Fabrice GASNIER <fabrice.gasnier@st.com> Reviewed-by: CIBUILD <smet-aci-builds@lists.codex.cro.st.com> Tested-by: Erwan LE RAY <erwan.leray@st.com>
1 parent 55988b6 commit 1cb30cb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/tty/serial/stm32-usart.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,10 +1196,12 @@ static int stm32_of_dma_rx_probe(struct stm32_port *stm32port,
11961196
int ret;
11971197

11981198
/* Request DMA RX channel */
1199-
stm32port->rx_ch = dma_request_slave_channel(dev, "rx");
1200-
if (!stm32port->rx_ch) {
1199+
stm32port->rx_ch = dma_request_chan_linked(dev, "rx");
1200+
if (IS_ERR(stm32port->rx_ch)) {
1201+
ret = PTR_ERR(stm32port->rx_ch);
1202+
stm32port->rx_ch = NULL;
12011203
dev_dbg(dev, "cannot get the DMA channel.\n");
1202-
return -ENODEV;
1204+
return ret;
12031205
}
12041206
stm32port->rx_buf = dma_alloc_coherent(&pdev->dev, RX_BUF_L,
12051207
&stm32port->rx_dma_buf,
@@ -1229,7 +1231,7 @@ static int stm32_of_dma_rx_probe(struct stm32_port *stm32port,
12291231
stm32port->rx_dma_buf);
12301232

12311233
alloc_err:
1232-
dma_release_channel(stm32port->rx_ch);
1234+
dma_release_chan_linked(dev, stm32port->rx_ch);
12331235
stm32port->rx_ch = NULL;
12341236

12351237
return ret;
@@ -1342,7 +1344,7 @@ static int stm32_serial_probe(struct platform_device *pdev)
13421344

13431345
err_dma:
13441346
if (stm32port->rx_ch)
1345-
dma_release_channel(stm32port->rx_ch);
1347+
dma_release_chan_linked(&pdev->dev, stm32port->rx_ch);
13461348

13471349
if (stm32port->rx_dma_buf)
13481350
dma_free_coherent(&pdev->dev,
@@ -1392,7 +1394,7 @@ static int stm32_serial_remove(struct platform_device *pdev)
13921394
writel_relaxed(cr3, port->membase + ofs->cr3);
13931395

13941396
if (stm32_port->rx_ch)
1395-
dma_release_channel(stm32_port->rx_ch);
1397+
dma_release_chan_linked(&pdev->dev, stm32_port->rx_ch);
13961398

13971399
if (stm32_port->rx_dma_buf)
13981400
dma_free_coherent(&pdev->dev,

0 commit comments

Comments
 (0)