tty: serial: extract lqasc_tx_ready() from lqasc_tx_chars()
authorJiri Slaby <jslaby@suse.cz>
Tue, 20 Sep 2022 05:20:44 +0000 (07:20 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Sep 2022 14:14:08 +0000 (16:14 +0200)
The condition in lqasc_tx_chars()'s loop is barely readable. Extract it
to a separate function. This will make the cleanup in the next patches
easier too.

(Put it before lqasc_start_tx(), so that we can use it there later.)

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220920052049.20507-5-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/lantiq.c

index 6637b3caa6b7908c650850189b08719093ec5a43..6da1b7496c6c4ad4a561000a49b7c5af51a62a0e 100644 (file)
@@ -139,6 +139,13 @@ lqasc_stop_tx(struct uart_port *port)
        return;
 }
 
+static bool lqasc_tx_ready(struct uart_port *port)
+{
+       u32 fstat = __raw_readl(port->membase + LTQ_ASC_FSTAT);
+
+       return (fstat & ASCFSTAT_TXFREEMASK) >> ASCFSTAT_TXFREEOFF;
+}
+
 static void
 lqasc_start_tx(struct uart_port *port)
 {
@@ -228,8 +235,7 @@ lqasc_tx_chars(struct uart_port *port)
                return;
        }
 
-       while (((__raw_readl(port->membase + LTQ_ASC_FSTAT) &
-               ASCFSTAT_TXFREEMASK) >> ASCFSTAT_TXFREEOFF) != 0) {
+       while (lqasc_tx_ready(port)) {
                if (port->x_char) {
                        writeb(port->x_char, port->membase + LTQ_ASC_TBUF);
                        port->icount.tx++;