Re: [PATCH v4 10/10] tty: serial: use uart_port_tx_limited()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 20 Sep 2022, Jiri Slaby wrote:

> uart_port_tx_limited() is a new helper to send characters to the device.
> Use it in these drivers.
> 
> mux.c also needs to define tx_done(). But I'm not sure if the driver
> really wants to wait for all the characters to dismiss from the HW fifo
> at this code point. Hence I marked this as FIXME.
> 
> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> Cc: Russell King <linux@xxxxxxxxxxxxxxx>
> Cc: Florian Fainelli <f.fainelli@xxxxxxxxx>
> Cc: bcm-kernel-feedback-list@xxxxxxxxxxxx
> Cc: "Pali Rohár" <pali@xxxxxxxxxx>
> Cc: Kevin Cernekee <cernekee@xxxxxxxxx>
> Cc: Palmer Dabbelt <palmer@xxxxxxxxxxx>
> Cc: Paul Walmsley <paul.walmsley@xxxxxxxxxx>
> Cc: Orson Zhai <orsonzhai@xxxxxxxxx>
> Cc: Baolin Wang <baolin.wang7@xxxxxxxxx>
> Cc: Chunyan Zhang <zhang.lyra@xxxxxxxxx>
> Cc: Patrice Chotard <patrice.chotard@xxxxxxxxxxx>
> Cc: linux-riscv@xxxxxxxxxxxxxxxxxxx

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>

One improvement suggestion below.

> diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
> index 23f339757894..f224f5141726 100644
> --- a/drivers/tty/serial/altera_jtaguart.c
> +++ b/drivers/tty/serial/altera_jtaguart.c
> @@ -137,39 +137,17 @@ static void altera_jtaguart_rx_chars(struct altera_jtaguart *pp)
>  static void altera_jtaguart_tx_chars(struct altera_jtaguart *pp)
>  {
>  	struct uart_port *port = &pp->port;
> -	struct circ_buf *xmit = &port->state->xmit;
> -	unsigned int pending, count;
> -
> -	if (port->x_char) {
> -		/* Send special char - probably flow control */
> -		writel(port->x_char, port->membase + ALTERA_JTAGUART_DATA_REG);
> -		port->x_char = 0;
> -		port->icount.tx++;
> -		return;
> -	}
> +	unsigned int space;
> +	u8 ch;
>  
> -	pending = uart_circ_chars_pending(xmit);
> -	if (pending > 0) {
> -		count = (readl(port->membase + ALTERA_JTAGUART_CONTROL_REG) &
> -				ALTERA_JTAGUART_CONTROL_WSPACE_MSK) >>
> -			ALTERA_JTAGUART_CONTROL_WSPACE_OFF;
> -		if (count > pending)
> -			count = pending;
> -		if (count > 0) {
> -			pending -= count;
> -			while (count--) {
> -				writel(xmit->buf[xmit->tail],
> -				       port->membase + ALTERA_JTAGUART_DATA_REG);
> -				xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
> -				port->icount.tx++;
> -			}
> -			if (pending < WAKEUP_CHARS)
> -				uart_write_wakeup(port);
> -		}
> -	}
> +	space = readl(port->membase + ALTERA_JTAGUART_CONTROL_REG);
> +	space &= ALTERA_JTAGUART_CONTROL_WSPACE_MSK;
> +	space >>= ALTERA_JTAGUART_CONTROL_WSPACE_OFF;

This is FIELD_GET(ALTERA_JTAGUART_CONTROL_WSPACE_MSK, ...) & then allows 
killing ALTERA_JTAGUART_CONTROL_WSPACE_OFF. I'd probably do it in a 
separate patch though.


-- 
 i.

[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux