serial: imx: unmap scatter gather list in imx_flush_buffer
authorDirk Behme <dirk.behme@de.bosch.com>
Tue, 9 Dec 2014 09:11:27 +0000 (18:11 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Jan 2015 22:23:07 +0000 (14:23 -0800)
First, reformat the code to exit immediately. This allows us to add
more code in more readable format.

In case the TX DMA was still running, remove and disable it's resources.

Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/imx.c

index b4cf24c64a150a29e80be09f16a700046d5ee13b..952730ab90671b9e9cabea6c30d9d19310f589dc 100644 (file)
@@ -1250,10 +1250,17 @@ static void imx_shutdown(struct uart_port *port)
 static void imx_flush_buffer(struct uart_port *port)
 {
        struct imx_port *sport = (struct imx_port *)port;
+       struct scatterlist *sgl = &sport->tx_sgl[0];
 
-       if (sport->dma_is_enabled) {
-               sport->tx_bytes = 0;
-               dmaengine_terminate_all(sport->dma_chan_tx);
+       if (!sport->dma_chan_tx)
+               return;
+
+       sport->tx_bytes = 0;
+       dmaengine_terminate_all(sport->dma_chan_tx);
+       if (sport->dma_is_txing) {
+               dma_unmap_sg(sport->port.dev, sgl, sport->dma_tx_nents,
+                            DMA_TO_DEVICE);
+               sport->dma_is_txing = false;
        }
 }