Skip to content

Commit

Permalink
serial: stm32: use dma_request/release_chan_linked API for rx
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/155328
Reviewed-by: CITOOLS <[email protected]>
Reviewed-by: Erwan LE RAY <[email protected]>
Reviewed-by: Fabrice GASNIER <[email protected]>
Reviewed-by: CIBUILD <[email protected]>
Tested-by: Erwan LE RAY <[email protected]>
  • Loading branch information
ADESTM committed Jan 20, 2020
1 parent 55988b6 commit 1cb30cb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions drivers/tty/serial/stm32-usart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,10 +1196,12 @@ static int stm32_of_dma_rx_probe(struct stm32_port *stm32port,
int ret;

/* Request DMA RX channel */
stm32port->rx_ch = dma_request_slave_channel(dev, "rx");
if (!stm32port->rx_ch) {
stm32port->rx_ch = dma_request_chan_linked(dev, "rx");
if (IS_ERR(stm32port->rx_ch)) {
ret = PTR_ERR(stm32port->rx_ch);
stm32port->rx_ch = NULL;
dev_dbg(dev, "cannot get the DMA channel.\n");
return -ENODEV;
return ret;
}
stm32port->rx_buf = dma_alloc_coherent(&pdev->dev, RX_BUF_L,
&stm32port->rx_dma_buf,
Expand Down Expand Up @@ -1229,7 +1231,7 @@ static int stm32_of_dma_rx_probe(struct stm32_port *stm32port,
stm32port->rx_dma_buf);

alloc_err:
dma_release_channel(stm32port->rx_ch);
dma_release_chan_linked(dev, stm32port->rx_ch);
stm32port->rx_ch = NULL;

return ret;
Expand Down Expand Up @@ -1342,7 +1344,7 @@ static int stm32_serial_probe(struct platform_device *pdev)

err_dma:
if (stm32port->rx_ch)
dma_release_channel(stm32port->rx_ch);
dma_release_chan_linked(&pdev->dev, stm32port->rx_ch);

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

if (stm32_port->rx_ch)
dma_release_channel(stm32_port->rx_ch);
dma_release_chan_linked(&pdev->dev, stm32_port->rx_ch);

if (stm32_port->rx_dma_buf)
dma_free_coherent(&pdev->dev,
Expand Down

0 comments on commit 1cb30cb

Please sign in to comment.