Skip to content

Commit 95a1b40

Browse files
jognessgregkh
authored andcommitted
serial: 8250: Use high-level writing function for FIFO
Currently serial8250_console_fifo_write() directly writes into the UART_TX register rather than using the high-level function serial8250_console_putchar(). This is because serial8250_console_putchar() waits for the holding register to become empty, which would defeat the purpose of the FIFO code. Move the LSR_THRE waiting to a new function serial8250_console_wait_putchar() so that the FIFO code can use serial8250_console_putchar(). This will be particularly important for a follow-up commit, where output bytes are inspected to track newlines. This is only refactoring and has no functional change. Signed-off-by: John Ogness <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8d5cfb1 commit 95a1b40

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/tty/serial/8250/8250_port.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3298,11 +3298,16 @@ EXPORT_SYMBOL_GPL(serial8250_set_defaults);
32983298
#ifdef CONFIG_SERIAL_8250_CONSOLE
32993299

33003300
static void serial8250_console_putchar(struct uart_port *port, unsigned char ch)
3301+
{
3302+
serial_port_out(port, UART_TX, ch);
3303+
}
3304+
3305+
static void serial8250_console_wait_putchar(struct uart_port *port, unsigned char ch)
33013306
{
33023307
struct uart_8250_port *up = up_to_u8250p(port);
33033308

33043309
wait_for_xmitr(up, UART_LSR_THRE);
3305-
serial_port_out(port, UART_TX, ch);
3310+
serial8250_console_putchar(port, ch);
33063311
}
33073312

33083313
/*
@@ -3352,6 +3357,7 @@ static void serial8250_console_fifo_write(struct uart_8250_port *up,
33523357
{
33533358
const char *end = s + count;
33543359
unsigned int fifosize = up->tx_loadsz;
3360+
struct uart_port *port = &up->port;
33553361
unsigned int tx_count = 0;
33563362
bool cr_sent = false;
33573363
unsigned int i;
@@ -3362,10 +3368,10 @@ static void serial8250_console_fifo_write(struct uart_8250_port *up,
33623368

33633369
for (i = 0; i < fifosize && s != end; ++i) {
33643370
if (*s == '\n' && !cr_sent) {
3365-
serial_out(up, UART_TX, '\r');
3371+
serial8250_console_putchar(port, '\r');
33663372
cr_sent = true;
33673373
} else {
3368-
serial_out(up, UART_TX, *s++);
3374+
serial8250_console_putchar(port, *s++);
33693375
cr_sent = false;
33703376
}
33713377
}
@@ -3445,7 +3451,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,
34453451
if (likely(use_fifo))
34463452
serial8250_console_fifo_write(up, s, count);
34473453
else
3448-
uart_console_write(port, s, count, serial8250_console_putchar);
3454+
uart_console_write(port, s, count, serial8250_console_wait_putchar);
34493455

34503456
/*
34513457
* Finally, wait for transmitter to become empty

0 commit comments

Comments
 (0)