]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
serial: Move carriage return before line feed for some serial drivers
authorAlison Wang <b18965@freescale.com>
Wed, 2 Mar 2016 03:00:37 +0000 (11:00 +0800)
committerSimon Glass <sjg@chromium.org>
Mon, 14 Mar 2016 21:34:50 +0000 (15:34 -0600)
In general, a carriage return needs to execute before a line feed.
The patch is to change some serial drivers based on this rule, such
as serial_mxc.c, serial_pxa.c, serial_s3c24x0.c and usbtty.c.

Signed-off-by: Alison Wang <alison.wang@nxp.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/serial/serial_mxc.c
drivers/serial/serial_pxa.c
drivers/serial/serial_s3c24x0.c
drivers/serial/usbtty.c

index 51485c0d095685a213e22cb70609e3a7459bcbae..1563bb3665b671073d34fb4ae4e459c68542e183 100644 (file)
@@ -164,15 +164,15 @@ static int mxc_serial_getc(void)
 
 static void mxc_serial_putc(const char c)
 {
+       /* If \n, also do \r */
+       if (c == '\n')
+               serial_putc('\r');
+
        __REG(UART_PHYS + UTXD) = c;
 
        /* wait for transmitter to be ready */
        while (!(__REG(UART_PHYS + UTS) & UTS_TXEMPTY))
                WATCHDOG_RESET();
-
-       /* If \n, also do \r */
-       if (c == '\n')
-               serial_putc ('\r');
 }
 
 /*
index 8fbcc10248f04dc8cb827a1a4c152cafd0b87376..1eb19ececdfdd514a6d59e6a25ee01507dfaaab8 100644 (file)
@@ -156,6 +156,10 @@ void pxa_putc_dev(unsigned int uart_index, const char c)
 {
        struct pxa_uart_regs *uart_regs;
 
+       /* If \n, also do \r */
+       if (c == '\n')
+               pxa_putc_dev(uart_index, '\r');
+
        uart_regs = pxa_uart_index_to_regs(uart_index);
        if (!uart_regs)
                hang();
@@ -163,10 +167,6 @@ void pxa_putc_dev(unsigned int uart_index, const char c)
        while (!(readl(&uart_regs->lsr) & LSR_TEMT))
                WATCHDOG_RESET();
        writel(c, &uart_regs->thr);
-
-       /* If \n, also do \r */
-       if (c == '\n')
-               pxa_putc_dev (uart_index,'\r');
 }
 
 /*
index d4e7df27be1ffe98e2f6ab5ec17e290cb765b6d1..0f0878a0510de1ccff4132c9ded65b355b9a4386 100644 (file)
@@ -135,14 +135,14 @@ static void _serial_putc(const char c, const int dev_index)
 {
        struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
 
+       /* If \n, also do \r */
+       if (c == '\n')
+               serial_putc('\r');
+
        while (!(readl(&uart->utrstat) & 0x2))
                /* wait for room in the tx FIFO */ ;
 
        writeb(c, &uart->utxh);
-
-       /* If \n, also do \r */
-       if (c == '\n')
-               serial_putc('\r');
 }
 
 static inline void serial_putc_dev(unsigned int dev_index, const char c)
index 75f0ec31bbfb9a6faedeaf9cf137ea1212ceefd5..2e19813643bb093aa82f237db83627f7f028de1d 100644 (file)
@@ -434,11 +434,12 @@ void usbtty_putc(struct stdio_dev *dev, const char c)
        if (!usbtty_configured ())
                return;
 
-       buf_push (&usbtty_output, &c, 1);
        /* If \n, also do \r */
        if (c == '\n')
                buf_push (&usbtty_output, "\r", 1);
 
+       buf_push(&usbtty_output, &c, 1);
+
        /* Poll at end to handle new data... */
        if ((usbtty_output.size + 2) >= usbtty_output.totalsize) {
                usbtty_poll ();
@@ -498,8 +499,8 @@ void usbtty_puts(struct stdio_dev *dev, const char *str)
                n = next_nl_pos (str);
 
                if (str[n] == '\n') {
-                       __usbtty_puts (str, n + 1);
-                       __usbtty_puts ("\r", 1);
+                       __usbtty_puts("\r", 1);
+                       __usbtty_puts(str, n + 1);
                        str += (n + 1);
                        len -= (n + 1);
                } else {