Re: [PATCH v2 2/3] tty: serial: use DEFINE_UART_PORT_TX_HELPER()

From: Jiri Slaby
Date: Tue Sep 06 2022 - 06:53:27 EST


On 02. 09. 22, 16:21, Ilpo Järvinen wrote:
--- a/drivers/tty/serial/sa1100.c
+++ b/drivers/tty/serial/sa1100.c
@@ -226,45 +226,34 @@ sa1100_rx_chars(struct sa1100_port *sport)
tty_flip_buffer_push(&sport->port.state->port);
}
-static void sa1100_tx_chars(struct sa1100_port *sport)
+static bool sa1100_tx_ready(struct uart_port *port)
{
- struct circ_buf *xmit = &sport->port.state->xmit;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
- if (sport->port.x_char) {
- UART_PUT_CHAR(sport, sport->port.x_char);
- sport->port.icount.tx++;
- sport->port.x_char = 0;
- return;
- }
+ return UART_GET_UTSR1(sport) & UTSR1_TNF;
+}
+
+static void sa1100_put_char(struct uart_port *port, unsigned char ch)
+{
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
+
+ UART_PUT_CHAR(sport, ch);
+}

Perhaps not to add into this change itself, but I just point out these
would be useful in addition to what is changed:
- Get rid of UART_PUT_CHAR()

Right, that would make the above easier.

- sa1100_console_putchar() could use sa1100_tx_ready()
That could be a nice cleanup. But looking at the history, I am not sure anyone cares enough about the driver (and cleaning it up :P). And I'm not much into it.

I've just sent v3 including your comments addressed.

thanks,
--
js
suse labs