serial: Fix the error handling for carriage return and line feed
cover serial: Fix the error handling for carriage return and line feed
This serial is to fix the error handling for carriage return and line feed.
----------------------------------------------------------------
Alison Wang (3):
dm: serial-uclass: Move a carriage return before a line feed
serial: Move carriage return before line feed for some serial drivers
dm: serial: Remove duplicated carriage return character
drivers/serial/serial-uclass.c | 5 +++-- drivers/serial/serial_arc.c | 3 --- drivers/serial/serial_lpuart.c | 6 ------ drivers/serial/serial_mxc.c | 8 ++++---- drivers/serial/serial_pxa.c | 8 ++++---- drivers/serial/serial_s3c24x0.c | 8 ++++---- drivers/serial/usbtty.c | 7 ++++--- 7 files changed, 19 insertions(+), 26 deletions(-)
PATCH 1/3 dm: serial-uclass: Move a carriage return before a line feed
In general, a carriage return needs to execute before a line feed. The patch is to change serial DM driver serial-uclass.c based on this rule.
--- drivers/serial/serial-uclass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/serial/serial-uclass.c +3 -2
@@ -123,11 +123,12 @@ static void _serial_putc(struct udevice *dev, char ch)struct dm_serial_ops *ops =serial_get_ops (dev);int err; +if (ch =='\n' ) +_serial_putc (dev,'\r' ); +do { err = ops->putc (dev, ch); }while (err == -EAGAIN ); -if (ch =='\n' ) -_serial_putc (dev,'\r' ); }static void _serial_puts (struct udevice *dev,const char *str)
Signature · 1 line
2.1.0.27.g96db324
PATCH 2/3 serial: Move carriage return before line feed for some serial drivers
In reply to Alison WangIn 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.
--- drivers/serial/serial_mxc.c | 8 ++++---- drivers/serial/serial_pxa.c | 8 ++++---- drivers/serial/serial_s3c24x0.c | 8 ++++---- drivers/serial/usbtty.c | 7 ++++--- 4 files changed, 16 insertions(+), 15 deletions(-)
drivers/serial/serial_mxc.c +4 -4
@@ -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' ); }/*
drivers/serial/serial_pxa.c +4 -4
@@ -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' ); }/*
drivers/serial/serial_s3c24x0.c +4 -4
@@ -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)
drivers/serial/usbtty.c +4 -3
@@ -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 {
Signature · 1 line
2.1.0.27.g96db324
PATCH 3/3 dm: serial: Remove duplicated carriage return character
In reply to Alison WangAs the handling for carriage return and line feed is done in the common DM driver serial-uclass.c, such handling in some serial DM drivers is duplicated and need to be removed.
--- drivers/serial/serial_arc.c | 3 --- drivers/serial/serial_lpuart.c | 6 ------ 2 files changed, 9 deletions(-)
drivers/serial/serial_arc.c +0 -3
@@ -68,9 +68,6 @@ static int arc_serial_putc(struct udevice *dev, const char c)struct arc_serial_platdata *plat = dev->platdata;struct arc_serial_regs *const regs = plat->reg; -if (c =='\n' ) -arc_serial_putc (dev,'\r' ); -while (!(readb (®s->status) &UART_TXEMPTY )) ;
drivers/serial/serial_lpuart.c +0 -6
@@ -77,9 +77,6 @@ static int _lpuart_serial_getc(struct lpuart_fsl *base)static void _lpuart_serial_putc (struct lpuart_fsl *base,const char c) { -if (c =='\n' ) -_lpuart_serial_putc (base,'\r' ); -while (!(__raw_readb (&base->us1) &US1_TDRE ))WATCHDOG_RESET ();
@@ -198,9 +195,6 @@ static int _lpuart32_serial_getc(struct lpuart_fsl *base)static void _lpuart32_serial_putc (struct lpuart_fsl *base,const char c) { -if (c =='\n' ) -_lpuart32_serial_putc (base,'\r' ); -while (!(in_be32 (&base->stat) &STAT_TDRE ))WATCHDOG_RESET ();
Signature · 1 line
2.1.0.27.g96db324
PATCH 1/3 dm: serial-uclass: Move a carriage return before a line feed
In reply to Alison WangQuoted 8 lines · Alison Wang
In general, a carriage return needs to execute before a line feed. The patch is to change serial DM driver
serial-uclass.cbased on this rule.Signed-off-by Alison Wang <[email protected]>--- drivers/serial/serial-uclass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
PATCH 2/3 serial: Move carriage return before line feed for some serial drivers
In reply to Alison WangQuoted 4 lines · Alison Wang
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.candusbtty.c.
Quoted 8 lines
Signed-off-by Alison Wang <[email protected]>--- drivers/serial/serial_mxc.c | 8 ++++---- drivers/serial/serial_pxa.c | 8 ++++---- drivers/serial/serial_s3c24x0.c | 8 ++++---- drivers/serial/usbtty.c | 7 ++++--- 4 files changed, 16 insertions(+), 15 deletions(-)
PATCH 3/3 dm: serial: Remove duplicated carriage return character
In reply to Alison WangQuoted 10 lines · Alison Wang
As the handling for carriage return and line feed is done in the common DM driver
serial-uclass.c, such handling in some serial DM drivers is duplicated and need to be removed.Signed-off-by Alison Wang <[email protected]>--- drivers/serial/serial_arc.c | 3 --- drivers/serial/serial_lpuart.c | 6 ------ 2 files changed, 9 deletions(-)
PATCH 1/3 dm: serial-uclass: Move a carriage return before a line feed
In reply to Bin MengQuoted 11 lines · Bin Meng
Quoted 8 lines · Alison Wang
In general, a carriage return needs to execute before a line feed. The patch is to change serial DM driver
serial-uclass.cbased on this rule.Signed-off-by Alison Wang <[email protected]>--- drivers/serial/serial-uclass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)Reviewed-by Bin Meng <[email protected]>
Applied to u-boot-dm/next, thanks!
PATCH 2/3 serial: Move carriage return before line feed for some serial drivers
In reply to Bin MengQuoted 14 lines · Bin Meng
Quoted 4 lines · Alison Wang
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.candusbtty.c.Quoted 8 lines
Signed-off-by Alison Wang <[email protected]>--- drivers/serial/serial_mxc.c | 8 ++++---- drivers/serial/serial_pxa.c | 8 ++++---- drivers/serial/serial_s3c24x0.c | 8 ++++---- drivers/serial/usbtty.c | 7 ++++--- 4 files changed, 16 insertions(+), 15 deletions(-)
Quoted 1 line
Reviewed-by Bin Meng <[email protected]>
Applied to u-boot-dm/next, thanks!
PATCH 3/3 dm: serial: Remove duplicated carriage return character
In reply to Bin MengQuoted 5 lines · Bin Meng
Quoted 4 lines · Alison Wang
As the handling for carriage return and line feed is done in the common DM driver
serial-uclass.c, such handling in some serial DM drivers is duplicated and need to be removed.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Alison Wang <[email protected]>--- drivers/serial/serial_arc.c | 3 --- drivers/serial/serial_lpuart.c | 6 ------ 2 files changed, 9 deletions(-)Reviewed-by Bin Meng <[email protected]>
Applied to u-boot-dm/next, thanks!