Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial_core: Commonalize crlf when working w/ a non open console port

In (efe2f29 kgdboc,kdb: Allow kdb to work on a non open console port)
support was added to directly use the "write_char" functions when
doing kdb over a non-open console port. This is great, but it ends up
bypassing the normal code in uart_console_write() that adds a carriage
return before any newlines.

There appears to have been a trend to add this support directly in
some console driver's poll_put_char() functions. This had a few side
effects, including:
- In this case we were doing LFCR, not CRLF. This was fixed in
uart_console_write() back in (d358788 [SERIAL] kernel console should
send CRLF not LFCR)
- Not all serial drivers had the LFCR code in their poll_put_char()
functions. In my case I was running serial/samsung.c which lacked
it.

I've moved the handling to uart_poll_put_char() to fix the above
problems. Now when I use kdb (and don't point console= to the same
UART) I no longer get:

[0]kdb>
[0]kdb>
[0]kdb>

Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Doug Anderson and committed by
Greg Kroah-Hartman
c7d44a02 0f1e126b

+3 -20
-5
drivers/tty/serial/8250/8250_core.c
··· 1926 1926 wait_for_xmitr(up, BOTH_EMPTY); 1927 1927 /* 1928 1928 * Send the character out. 1929 - * If a LF, also do CR... 1930 1929 */ 1931 1930 serial_port_out(port, UART_TX, c); 1932 - if (c == 10) { 1933 - wait_for_xmitr(up, BOTH_EMPTY); 1934 - serial_port_out(port, UART_TX, 13); 1935 - } 1936 1931 1937 1932 /* 1938 1933 * Finally, wait for transmitter to become empty
-5
drivers/tty/serial/pch_uart.c
··· 1590 1590 wait_for_xmitr(priv, UART_LSR_THRE); 1591 1591 /* 1592 1592 * Send the character out. 1593 - * If a LF, also do CR... 1594 1593 */ 1595 1594 iowrite8(c, priv->membase + PCH_UART_THR); 1596 - if (c == 10) { 1597 - wait_for_xmitr(priv, UART_LSR_THRE); 1598 - iowrite8(13, priv->membase + PCH_UART_THR); 1599 - } 1600 1595 1601 1596 /* 1602 1597 * Finally, wait for transmitter to become empty
-5
drivers/tty/serial/pxa.c
··· 711 711 wait_for_xmitr(up); 712 712 /* 713 713 * Send the character out. 714 - * If a LF, also do CR... 715 714 */ 716 715 serial_out(up, UART_TX, c); 717 - if (c == 10) { 718 - wait_for_xmitr(up); 719 - serial_out(up, UART_TX, 13); 720 - } 721 716 722 717 /* 723 718 * Finally, wait for transmitter to become empty
+3
drivers/tty/serial/serial_core.c
··· 2236 2236 return; 2237 2237 2238 2238 port = state->uart_port; 2239 + 2240 + if (ch == '\n') 2241 + port->ops->poll_put_char(port, '\r'); 2239 2242 port->ops->poll_put_char(port, ch); 2240 2243 } 2241 2244 #endif
-5
drivers/tty/serial/serial_txx9.c
··· 535 535 wait_for_xmitr(up); 536 536 /* 537 537 * Send the character out. 538 - * If a LF, also do CR... 539 538 */ 540 539 sio_out(up, TXX9_SITFIFO, c); 541 - if (c == 10) { 542 - wait_for_xmitr(up); 543 - sio_out(up, TXX9_SITFIFO, 13); 544 - } 545 540 546 541 /* 547 542 * Finally, wait for transmitter to become empty