Re: [PATCH v4 09/10] tty: serial: use uart_port_tx() helper

From: Ilpo Järvinen
Date: Tue Sep 20 2022 - 04:54:38 EST


On Tue, 20 Sep 2022, Jiri Slaby wrote:

> uart_port_tx() is a new helper to send characters to the device. Use it
> in these drivers.
>
> Cc: Tobias Klauser <tklauser@xxxxxxxxxx>
> Cc: Richard Genoud <richard.genoud@xxxxxxxxx>
> Cc: Nicolas Ferre <nicolas.ferre@xxxxxxxxxxxxx>
> Cc: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>
> Cc: Claudiu Beznea <claudiu.beznea@xxxxxxxxxxxxx>
> Cc: Vladimir Zapolskiy <vz@xxxxxxxxx>
> Cc: Liviu Dudau <liviu.dudau@xxxxxxx>
> Cc: Sudeep Holla <sudeep.holla@xxxxxxx>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@xxxxxxx>
> Cc: Shawn Guo <shawnguo@xxxxxxxxxx>
> Cc: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
> Cc: Pengutronix Kernel Team <kernel@xxxxxxxxxxxxxx>
> Cc: Fabio Estevam <festevam@xxxxxxxxx>
> Cc: NXP Linux Team <linux-imx@xxxxxxx>
> Cc: "Andreas Färber" <afaerber@xxxxxxx>
> Cc: Manivannan Sadhasivam <mani@xxxxxxxxxx>
> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> ---

> diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
> index b1cd9a76dd93..53b642ea46ba 100644
> --- a/drivers/tty/serial/mcf.c
> +++ b/drivers/tty/serial/mcf.c
> @@ -327,29 +327,13 @@ static void mcf_rx_chars(struct mcf_uart *pp)
> static void mcf_tx_chars(struct mcf_uart *pp)
> {
> struct uart_port *port = &pp->port;
> - struct circ_buf *xmit = &port->state->xmit;
> -
> - if (port->x_char) {
> - /* Send special char - probably flow control */
> - writeb(port->x_char, port->membase + MCFUART_UTB);
> - port->x_char = 0;
> - port->icount.tx++;
> - return;
> - }
> -
> - while (readb(port->membase + MCFUART_USR) & MCFUART_USR_TXREADY) {
> - if (uart_circ_empty(xmit))
> - break;
> - writeb(xmit->buf[xmit->tail], port->membase + MCFUART_UTB);
> - xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE -1);
> - port->icount.tx++;
> - }
> -
> - if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
> - uart_write_wakeup(port);
> + unsigned int pending;
> + u8 ch;
>
> - if (uart_circ_empty(xmit)) {
> - mcf_stop_tx(port);
> + pending = uart_port_tx(port, ch,
> + readb(port->membase + MCFUART_USR) & MCFUART_USR_TXREADY,
> + writeb(ch, port->membase + MCFUART_UTB));
> + if (!pending) {

Why unsigned int pending here and bool pending in the other cases?

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


--
i.