]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/tty/serial/pch_uart.c
tty: serial: pch_uart: correct usage of dma_unmap_sg
[mirror_ubuntu-bionic-kernel.git] / drivers / tty / serial / pch_uart.c
index 760d5dd0aada2e34b198c70727741c671ed0ad16..d5f28052b54c576ee72d87482270802456e1253a 100644 (file)
@@ -235,6 +235,7 @@ struct eg20t_port {
        struct dma_chan                 *chan_rx;
        struct scatterlist              *sg_tx_p;
        int                             nent;
+       int                             orig_nent;
        struct scatterlist              sg_rx;
        int                             tx_dma_use;
        void                            *rx_buf_virt;
@@ -789,9 +790,10 @@ static void pch_dma_tx_complete(void *arg)
        }
        xmit->tail &= UART_XMIT_SIZE - 1;
        async_tx_ack(priv->desc_tx);
-       dma_unmap_sg(port->dev, sg, priv->nent, DMA_TO_DEVICE);
+       dma_unmap_sg(port->dev, sg, priv->orig_nent, DMA_TO_DEVICE);
        priv->tx_dma_use = 0;
        priv->nent = 0;
+       priv->orig_nent = 0;
        kfree(priv->sg_tx_p);
        pch_uart_hal_enable_interrupt(priv, PCH_UART_HAL_TX_INT);
 }
@@ -1015,6 +1017,7 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv)
                dev_err(priv->port.dev, "%s:dma_map_sg Failed\n", __func__);
                return 0;
        }
+       priv->orig_nent = num;
        priv->nent = nent;
 
        for (i = 0; i < nent; i++, sg++) {