serial_core: Commonalize crlf when working w/ a non open console port
authorDoug Anderson <dianders@chromium.org>
Mon, 21 Apr 2014 17:06:43 +0000 (10:06 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Apr 2014 23:13:01 +0000 (16:13 -0700)
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>
drivers/tty/serial/8250/8250_core.c
drivers/tty/serial/pch_uart.c
drivers/tty/serial/pxa.c
drivers/tty/serial/serial_core.c
drivers/tty/serial/serial_txx9.c

index 81f909c2101f6145f568fd048b60453533cf943d..ffee9825fbac696a53721cb2fd15ccc246522a77 100644 (file)
@@ -1926,13 +1926,8 @@ static void serial8250_put_poll_char(struct uart_port *port,
        wait_for_xmitr(up, BOTH_EMPTY);
        /*
         *      Send the character out.
-        *      If a LF, also do CR...
         */
        serial_port_out(port, UART_TX, c);
-       if (c == 10) {
-               wait_for_xmitr(up, BOTH_EMPTY);
-               serial_port_out(port, UART_TX, 13);
-       }
 
        /*
         *      Finally, wait for transmitter to become empty
index e194bb32b27bb5f6fedc43afd2bbf6887ed2c773..0cb6a8e52bd08669fda3d830a39819b5c5af792f 100644 (file)
@@ -1590,13 +1590,8 @@ static void pch_uart_put_poll_char(struct uart_port *port,
        wait_for_xmitr(priv, UART_LSR_THRE);
        /*
         * Send the character out.
-        * If a LF, also do CR...
         */
        iowrite8(c, priv->membase + PCH_UART_THR);
-       if (c == 10) {
-               wait_for_xmitr(priv, UART_LSR_THRE);
-               iowrite8(13, priv->membase + PCH_UART_THR);
-       }
 
        /*
         * Finally, wait for transmitter to become empty
index f9f20f38376003efc35691196e3baae6dae2c2da..9e7ee39f8b2a6c1ac58fcadc75e4bca49e847b01 100644 (file)
@@ -711,13 +711,8 @@ static void serial_pxa_put_poll_char(struct uart_port *port,
        wait_for_xmitr(up);
        /*
         *      Send the character out.
-        *      If a LF, also do CR...
         */
        serial_out(up, UART_TX, c);
-       if (c == 10) {
-               wait_for_xmitr(up);
-               serial_out(up, UART_TX, 13);
-       }
 
        /*
         *      Finally, wait for transmitter to become empty
index f26834d262b3a8d540a96455480fa4d5b6a1a81e..5dba9766f626397ef5619a40f613001238a26eae 100644 (file)
@@ -2236,6 +2236,9 @@ static void uart_poll_put_char(struct tty_driver *driver, int line, char ch)
                return;
 
        port = state->uart_port;
+
+       if (ch == '\n')
+               port->ops->poll_put_char(port, '\r');
        port->ops->poll_put_char(port, ch);
 }
 #endif
index 90a080b1f9ee13cd78d6647245ee91eb1c710da4..60f49b9d7e3921c2c72b9355502c1b1b5142a4b8 100644 (file)
@@ -535,13 +535,8 @@ static void serial_txx9_put_poll_char(struct uart_port *port, unsigned char c)
        wait_for_xmitr(up);
        /*
         *      Send the character out.
-        *      If a LF, also do CR...
         */
        sio_out(up, TXX9_SITFIFO, c);
-       if (c == 10) {
-               wait_for_xmitr(up);
-               sio_out(up, TXX9_SITFIFO, 13);
-       }
 
        /*
         *      Finally, wait for transmitter to become empty