From 1cb30cb5ffc29a53ec2031b6a29878ddd266516c Mon Sep 17 00:00:00 2001 From: Amelie Delaunay Date: Fri, 17 Jan 2020 11:45:43 +0100 Subject: [PATCH] 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 Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/155328 Reviewed-by: CITOOLS Reviewed-by: Erwan LE RAY Reviewed-by: Fabrice GASNIER Reviewed-by: CIBUILD Tested-by: Erwan LE RAY --- drivers/tty/serial/stm32-usart.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 98d73e540f1dd1..c6acbcfd129efc 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -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, @@ -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; @@ -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, @@ -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,