[04/44] serial: pch_uart: Use uart_xmit_advance()

Message ID 20221019091151.6692-5-ilpo.jarvinen@linux.intel.com
State New
Headers
Series serial: Convert drivers to use uart_xmit_advance() |

Commit Message

Ilpo Järvinen Oct. 19, 2022, 9:11 a.m. UTC
  Take advantage of the new uart_xmit_advance() helper.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/pch_uart.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
  

Comments

Andy Shevchenko Oct. 19, 2022, 11:11 a.m. UTC | #1
On Wed, Oct 19, 2022 at 12:11:11PM +0300, Ilpo Järvinen wrote:
> Take advantage of the new uart_xmit_advance() helper.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>  drivers/tty/serial/pch_uart.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
> index c59ce7886579..c76719c0f453 100644
> --- a/drivers/tty/serial/pch_uart.c
> +++ b/drivers/tty/serial/pch_uart.c
> @@ -738,15 +738,12 @@ static void pch_dma_tx_complete(void *arg)
>  {
>  	struct eg20t_port *priv = arg;
>  	struct uart_port *port = &priv->port;
> -	struct circ_buf *xmit = &port->state->xmit;
>  	struct scatterlist *sg = priv->sg_tx_p;
>  	int i;
>  
> -	for (i = 0; i < priv->nent; i++, sg++) {
> -		xmit->tail += sg_dma_len(sg);
> -		port->icount.tx += sg_dma_len(sg);
> -	}
> -	xmit->tail &= UART_XMIT_SIZE - 1;
> +	for (i = 0; i < priv->nent; i++, sg++)
> +		uart_xmit_advance(port, sg_dma_len(sg));
> +
>  	async_tx_ack(priv->desc_tx);
>  	dma_unmap_sg(port->dev, sg, priv->orig_nent, DMA_TO_DEVICE);
>  	priv->tx_dma_use = 0;
> @@ -843,8 +840,7 @@ static unsigned int handle_tx(struct eg20t_port *priv)
>  
>  	while (!uart_tx_stopped(port) && !uart_circ_empty(xmit) && fifo_size) {
>  		iowrite8(xmit->buf[xmit->tail], priv->membase + PCH_UART_THR);
> -		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
> -		port->icount.tx++;
> +		uart_xmit_advance(port, 1);
>  		fifo_size--;
>  		tx_empty = 0;
>  	}
> -- 
> 2.30.2
>
  

Patch

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index c59ce7886579..c76719c0f453 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -738,15 +738,12 @@  static void pch_dma_tx_complete(void *arg)
 {
 	struct eg20t_port *priv = arg;
 	struct uart_port *port = &priv->port;
-	struct circ_buf *xmit = &port->state->xmit;
 	struct scatterlist *sg = priv->sg_tx_p;
 	int i;
 
-	for (i = 0; i < priv->nent; i++, sg++) {
-		xmit->tail += sg_dma_len(sg);
-		port->icount.tx += sg_dma_len(sg);
-	}
-	xmit->tail &= UART_XMIT_SIZE - 1;
+	for (i = 0; i < priv->nent; i++, sg++)
+		uart_xmit_advance(port, sg_dma_len(sg));
+
 	async_tx_ack(priv->desc_tx);
 	dma_unmap_sg(port->dev, sg, priv->orig_nent, DMA_TO_DEVICE);
 	priv->tx_dma_use = 0;
@@ -843,8 +840,7 @@  static unsigned int handle_tx(struct eg20t_port *priv)
 
 	while (!uart_tx_stopped(port) && !uart_circ_empty(xmit) && fifo_size) {
 		iowrite8(xmit->buf[xmit->tail], priv->membase + PCH_UART_THR);
-		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
-		port->icount.tx++;
+		uart_xmit_advance(port, 1);
 		fifo_size--;
 		tx_empty = 0;
 	}