Consistently translate LF to CRLF on serial console
Subsystems (2)
PATCH 1/1 Consistently translate LF to CRLF on serial console
Some serial console drivers translate LF to CRLF, some do LFCR. This patch changes them to consistently translate to CRLF.
Andreas.
drivers/macintosh/macserial.c +6 -6
@@ -2736,12 +2736,6 @@write_zsreg (info->zs_channel,R5 , info->curregs[5 ] | TxENAB |RTS |DTR );for (i=0 ; i<count; i++) { -/* Wait for the transmit buffer to empty. */ -while ((read_zsreg (info->zs_channel,0 ) & Tx_BUF_EMP) ==0 ) { -eieio (); - } - -write_zsdata (info->zs_channel, s[i]);if (s[i] ==10 ) {while ((read_zsreg (info->zs_channel,0 ) & Tx_BUF_EMP) ==0 )
@@ -2749,6 +2743,12 @@write_zsdata (info->zs_channel,13 ); } +/* Wait for the transmit buffer to empty. */ +while ((read_zsreg (info->zs_channel,0 ) & Tx_BUF_EMP) ==0 ) { +eieio (); + } + +write_zsdata (info->zs_channel, s[i]); }/* Restore the values in the registers. */
drivers/serial/21285.c +3 -3
@@ -409,14 +409,14 @@int i;for (i =0 ; i < count; i++) { -while (*CSR_UARTFLG &0x20 ) -barrier (); - *CSR_UARTDR = s[i];if (s[i] =='\n' ) {while (*CSR_UARTFLG &0x20 )barrier (); *CSR_UARTDR ='\r' ; } +while (*CSR_UARTFLG &0x20 ) +barrier (); + *CSR_UARTDR = s[i]; } }
drivers/serial/68360serial.c +16 -16
@@ -2193,6 +2193,22 @@* buffer, but we would just wait longer between accesses...... */ for (i =0 ; i < count; i++, s++) { +/* if a LF, also do CR... */ +if (*s ==10 ) { +while (bdp->status &BD_SC_READY ); +/* cp = __va(bdp->buf); */ + cp = bdp->buf; + *cp =13 ; + bdp->length =1 ; + bdp->status |=BD_SC_READY ; + +if (bdp->status &BD_SC_WRAP ) { + bdp = bdbase; + } +else { + bdp++; + } + }/* Wait for transmitter fifo to empty. * Ready indicates output is ready, and xmt is doing * that, not that it is ready for us to send.
@@ -2212,22 +2228,6 @@else bdp++; -/* if a LF, also do CR... */ -if (*s ==10 ) { -while (bdp->status &BD_SC_READY ); -/* cp = __va(bdp->buf); */ - cp = bdp->buf; - *cp =13 ; - bdp->length =1 ; - bdp->status |=BD_SC_READY ; - -if (bdp->status &BD_SC_WRAP ) { - bdp = bdbase; - } -else { - bdp++; - } - } }/*
drivers/serial/8250.c +2 -3
@@ -1935,17 +1935,16 @@* Now, do each character */ for (i =0 ; i < count; i++, s++) { -wait_for_xmitr (up); -/* * Send the character out. * If a LF, also do CR... */ -serial_out (up,UART_TX , *s);if (*s ==10 ) {wait_for_xmitr (up);serial_out (up,UART_TX ,13 ); } +wait_for_xmitr (up); +serial_out (up,UART_TX , *s); }/*
drivers/serial/amba.c +4 -4
@@ -620,16 +620,16 @@* Now, do each character */ for (i =0 ; i < count; i++) { -do { - status =UART_GET_FR (port); - }while (!UART_TX_READY (status)); -UART_PUT_CHAR (port, s[i]);if (s[i] =='\n' ) {do { status =UART_GET_FR (port); }while (!UART_TX_READY (status));UART_PUT_CHAR (port,'\r' ); } +do { + status =UART_GET_FR (port); + }while (!UART_TX_READY (status)); +UART_PUT_CHAR (port, s[i]); }/*
drivers/serial/anakin.c +4 -6
@@ -411,16 +411,10 @@* Now, do each character */ for (i =0 ; i < count; i++, s++) { -while (!(anakin_in (port,0x10 ) &TXEMPTY )) -barrier (); -/* * Send the character out. * If a LF, also do CR... */ -anakin_out (port,0x14 , *s); -anakin_out (port,0x18 ,anakin_in (port,0x18 ) |SENDREQUEST ); -if (*s ==10 ) {while (!(anakin_in (port,0x10 ) &TXEMPTY ))barrier ();
@@ -428,6 +422,10 @@anakin_out (port,0x18 ,anakin_in (port,0x18 ) |SENDREQUEST ); } +while (!(anakin_in (port,0x10 ) &TXEMPTY )) +barrier (); +anakin_out (port,0x14 , *s); +anakin_out (port,0x18 ,anakin_in (port,0x18 ) |SENDREQUEST ); }/*
drivers/serial/clps711x.c +4 -4
@@ -473,16 +473,16 @@* Now, do each character */ for (i =0 ; i < count; i++) { -do { - status =clps_readl (SYSFLG (port)); - }while (status &SYSFLG_UTXFF ); -clps_writel (s[i],UARTDR (port));if (s[i] =='\n' ) {do { status =clps_readl (SYSFLG (port)); }while (status &SYSFLG_UTXFF );clps_writel ('\r' ,UARTDR (port)); } +do { + status =clps_readl (SYSFLG (port)); + }while (status &SYSFLG_UTXFF ); +clps_writel (s[i],UARTDR (port)); }/*
drivers/serial/pmac_zilog.c +4 -4
@@ -1892,15 +1892,15 @@write_zsreg (uap,R5 , uap->curregs[5 ] | TxENABLE |RTS |DTR );for (i =0 ; i < count; i++) { -/* Wait for the transmit buffer to empty. */ -while ((read_zsreg (uap,R0 ) & Tx_BUF_EMP) ==0 ) -udelay (5 ); -write_zsdata (uap, s[i]);if (s[i] ==10 ) {while ((read_zsreg (uap,R0 ) & Tx_BUF_EMP) ==0 )udelay (5 );write_zsdata (uap,R13 ); } +/* Wait for the transmit buffer to empty. */ +while ((read_zsreg (uap,R0 ) & Tx_BUF_EMP) ==0 ) +udelay (5 ); +write_zsdata (uap, s[i]); }/* Restore the values in the registers. */
drivers/serial/sa1100.c +4 -4
@@ -740,16 +740,16 @@* Now, do each character */ for (i =0 ; i < count; i++) { -do { - status =UART_GET_UTSR1 (sport); - }while (!(status &UTSR1_TNF )); -UART_PUT_CHAR (sport, s[i]);if (s[i] =='\n' ) {do { status =UART_GET_UTSR1 (sport); }while (!(status &UTSR1_TNF ));UART_PUT_CHAR (sport,'\r' ); } +do { + status =UART_GET_UTSR1 (sport); + }while (!(status &UTSR1_TNF )); +UART_PUT_CHAR (sport, s[i]); }/*
drivers/serial/serial98.c +2 -3
@@ -963,17 +963,16 @@* Now, do each character */ for (i =0 ; i < count; i++, s++) { -wait_for_xmitr (port); -/* * Send the character out. * If a LF, also do CR... */ -outb (*s,PORT .iobase);if (*s ==10 ) {wait_for_xmitr (port);outb (13 ,PORT .iobase); } +wait_for_xmitr (port); +outb (*s,PORT .iobase); }/*
drivers/serial/sunsu.c +2 -3
@@ -1382,17 +1382,16 @@* Now, do each character */ for (i =0 ; i < count; i++, s++) { -wait_for_xmitr (up); -/* * Send the character out. * If a LF, also do CR... */ -serial_out (up,UART_TX , *s);if (*s ==10 ) {wait_for_xmitr (up);serial_out (up,UART_TX ,13 ); } +wait_for_xmitr (up); +serial_out (up,UART_TX , *s); }/*
drivers/serial/sunzilog.c +1 -1
@@ -1338,9 +1338,9 @@spin_lock_irqsave (&up->port.lock, flags);for (i =0 ; i < count; i++, s++) { -sunzilog_put_char (channel, *s);if (*s ==10 )sunzilog_put_char (channel,13 ); +sunzilog_put_char (channel, *s); }udelay (2 );spin_unlock_irqrestore (&up->port.lock, flags);
drivers/serial/uart00.c +4 -4
@@ -553,16 +553,16 @@* Now, do each character */ for (i =0 ; i < count; i++) { -do { - status =UART_GET_TSR (port); - }while (!UART_TX_READY (status)); -UART_PUT_CHAR (port, s[i]);if (s[i] =='\n' ) {do { status =UART_GET_TSR (port); }while (!UART_TX_READY (status));UART_PUT_CHAR (port,'\r' ); } +do { + status =UART_GET_TSR (port); + }while (!UART_TX_READY (status)); +UART_PUT_CHAR (port, s[i]); }/*
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 2 lines · Andreas Schwab
Some serial console drivers translate LF to CRLF, some do LFCR. This patch changes them to consistently translate to CRLF.
macserial is obsolete (and will be soon removed), please look into pmac zilog rather. Also, why did you move the test for the transmit buffer empty ? You should at least check there is room in it _before_ writing to it
Quoted 334 lines
Andreas.
diff -ur
linux-2.6.4.orig/drivers/macintosh/macserial.clinux-2.6.4/drivers/macintosh/macserial.cdrivers/macintosh/macserial.c +6
-6@@ -2736,12 +2736,6 @@write_zsreg (info->zs_channel,R5 , info->curregs[5 ] | TxENAB |RTS |DTR );for (i=0 ; i<count; i++) { -/* Wait for the transmit buffer to empty. */ -while ((read_zsreg (info->zs_channel,0 ) & Tx_BUF_EMP) ==0 ) { -eieio (); - } - -write_zsdata (info->zs_channel, s[i]);if (s[i] ==10 ) {while ((read_zsreg (info->zs_channel,0 ) & Tx_BUF_EMP) ==0 )@@ -2749,6 +2743,12 @@write_zsdata (info->zs_channel,13 ); } +/* Wait for the transmit buffer to empty. */ +while ((read_zsreg (info->zs_channel,0 ) & Tx_BUF_EMP) ==0 ) { +eieio (); + } + +write_zsdata (info->zs_channel, s[i]); }/* Restore the values in the registers. */ diff -ur linux-2.6.4.orig/drivers/serial/21285.c linux-2.6.4/drivers/serial/21285.c
drivers/serial/21285.c +3
-3@@ -409,14 +409,14 @@int i;for (i =0 ; i < count; i++) { -while (*CSR_UARTFLG &0x20 ) -barrier (); - *CSR_UARTDR = s[i];if (s[i] =='\n' ) {while (*CSR_UARTFLG &0x20 )barrier (); *CSR_UARTDR ='\r' ; } +while (*CSR_UARTFLG &0x20 ) +barrier (); + *CSR_UARTDR = s[i]; } }diff -ur
linux-2.6.4.orig/drivers/serial/68360serial.clinux-2.6.4/drivers/serial/68360serial.cdrivers/serial/68360serial.c +16
-16@@ -2193,6 +2193,22 @@* buffer, but we would just wait longer between accesses...... */ for (i =0 ; i < count; i++, s++) { +/* if a LF, also do CR... */ +if (*s ==10 ) { +while (bdp->status &BD_SC_READY ); +/* cp = __va(bdp->buf); */ + cp = bdp->buf; + *cp =13 ; + bdp->length =1 ; + bdp->status |=BD_SC_READY ; + +if (bdp->status &BD_SC_WRAP ) { + bdp = bdbase; + } +else { + bdp++; + } + }/* Wait for transmitter fifo to empty. * Ready indicates output is ready, and xmt is doing * that, not that it is ready for us to send. @@ -2212,22 +2228,6 @@else bdp++; -/* if a LF, also do CR... */ -if (*s ==10 ) { -while (bdp->status &BD_SC_READY ); -/* cp = __va(bdp->buf); */ - cp = bdp->buf; - *cp =13 ; - bdp->length =1 ; - bdp->status |=BD_SC_READY ; - -if (bdp->status &BD_SC_WRAP ) { - bdp = bdbase; - } -else { - bdp++; - } - } }/* diff -ur linux-2.6.4.orig/drivers/serial/8250.c linux-2.6.4/drivers/serial/8250.c
drivers/serial/8250.c +2
-3@@ -1935,17 +1935,16 @@* Now, do each character */ for (i =0 ; i < count; i++, s++) { -wait_for_xmitr (up); -/* * Send the character out. * If a LF, also do CR... */ -serial_out (up,UART_TX , *s);if (*s ==10 ) {wait_for_xmitr (up);serial_out (up,UART_TX ,13 ); } +wait_for_xmitr (up); +serial_out (up,UART_TX , *s); }/* diff -ur
linux-2.6.4.orig/drivers/serial/amba.clinux-2.6.4/drivers/serial/amba.cdrivers/serial/amba.c +4
-4@@ -620,16 +620,16 @@* Now, do each character */ for (i =0 ; i < count; i++) { -do { - status =UART_GET_FR (port); - }while (!UART_TX_READY (status)); -UART_PUT_CHAR (port, s[i]);if (s[i] =='\n' ) {do { status =UART_GET_FR (port); }while (!UART_TX_READY (status));UART_PUT_CHAR (port,'\r' ); } +do { + status =UART_GET_FR (port); + }while (!UART_TX_READY (status)); +UART_PUT_CHAR (port, s[i]); }/* diff -ur
linux-2.6.4.orig/drivers/serial/anakin.clinux-2.6.4/drivers/serial/anakin.cdrivers/serial/anakin.c +4
-6@@ -411,16 +411,10 @@* Now, do each character */ for (i =0 ; i < count; i++, s++) { -while (!(anakin_in (port,0x10 ) &TXEMPTY )) -barrier (); -/* * Send the character out. * If a LF, also do CR... */ -anakin_out (port,0x14 , *s); -anakin_out (port,0x18 ,anakin_in (port,0x18 ) |SENDREQUEST ); -if (*s ==10 ) {while (!(anakin_in (port,0x10 ) &TXEMPTY ))barrier ();@@ -428,6 +422,10 @@anakin_out (port,0x18 ,anakin_in (port,0x18 ) |SENDREQUEST ); } +while (!(anakin_in (port,0x10 ) &TXEMPTY )) +barrier (); +anakin_out (port,0x14 , *s); +anakin_out (port,0x18 ,anakin_in (port,0x18 ) |SENDREQUEST ); }/* diff -ur
linux-2.6.4.orig/drivers/serial/clps711x.clinux-2.6.4/drivers/serial/clps711x.cdrivers/serial/clps711x.c +4
-4@@ -473,16 +473,16 @@* Now, do each character */ for (i =0 ; i < count; i++) { -do { - status =clps_readl (SYSFLG (port)); - }while (status &SYSFLG_UTXFF ); -clps_writel (s[i],UARTDR (port));if (s[i] =='\n' ) {do { status =clps_readl (SYSFLG (port)); }while (status &SYSFLG_UTXFF );clps_writel ('\r' ,UARTDR (port)); } +do { + status =clps_readl (SYSFLG (port)); + }while (status &SYSFLG_UTXFF ); +clps_writel (s[i],UARTDR (port)); }/* diff -ur
linux-2.6.4.orig/drivers/serial/pmac_zilog.clinux-2.6.4/drivers/serial/pmac_zilog.cdrivers/serial/pmac_zilog.c +4
-4@@ -1892,15 +1892,15 @@write_zsreg (uap,R5 , uap->curregs[5 ] | TxENABLE |RTS |DTR );for (i =0 ; i < count; i++) { -/* Wait for the transmit buffer to empty. */ -while ((read_zsreg (uap,R0 ) & Tx_BUF_EMP) ==0 ) -udelay (5 ); -write_zsdata (uap, s[i]);if (s[i] ==10 ) {while ((read_zsreg (uap,R0 ) & Tx_BUF_EMP) ==0 )udelay (5 );write_zsdata (uap,R13 ); } +/* Wait for the transmit buffer to empty. */ +while ((read_zsreg (uap,R0 ) & Tx_BUF_EMP) ==0 ) +udelay (5 ); +write_zsdata (uap, s[i]); }/* Restore the values in the registers. */ diff -ur
linux-2.6.4.orig/drivers/serial/sa1100.clinux-2.6.4/drivers/serial/sa1100.cdrivers/serial/sa1100.c +4
-4@@ -740,16 +740,16 @@* Now, do each character */ for (i =0 ; i < count; i++) { -do { - status =UART_GET_UTSR1 (sport); - }while (!(status &UTSR1_TNF )); -UART_PUT_CHAR (sport, s[i]);if (s[i] =='\n' ) {do { status =UART_GET_UTSR1 (sport); }while (!(status &UTSR1_TNF ));UART_PUT_CHAR (sport,'\r' ); } +do { + status =UART_GET_UTSR1 (sport); + }while (!(status &UTSR1_TNF )); +UART_PUT_CHAR (sport, s[i]); }/* diff -ur
linux-2.6.4.orig/drivers/serial/serial98.clinux-2.6.4/drivers/serial/serial98.cdrivers/serial/serial98.c +2
-3@@ -963,17 +963,16 @@* Now, do each character */ for (i =0 ; i < count; i++, s++) { -wait_for_xmitr (port); -/* * Send the character out. * If a LF, also do CR... */ -outb (*s,PORT .iobase);if (*s ==10 ) {wait_for_xmitr (port);outb (13 ,PORT .iobase); } +wait_for_xmitr (port); +outb (*s,PORT .iobase); }/* diff -ur
linux-2.6.4.orig/drivers/serial/sunsu.clinux-2.6.4/drivers/serial/sunsu.cdrivers/serial/sunsu.c +2
-3@@ -1382,17 +1382,16 @@* Now, do each character */ for (i =0 ; i < count; i++, s++) { -wait_for_xmitr (up); -/* * Send the character out. * If a LF, also do CR... */ -serial_out (up,UART_TX , *s);if (*s ==10 ) {wait_for_xmitr (up);serial_out (up,UART_TX ,13 ); } +wait_for_xmitr (up); +serial_out (up,UART_TX , *s); }/* diff -ur
linux-2.6.4.orig/drivers/serial/sunzilog.clinux-2.6.4/drivers/serial/sunzilog.cdrivers/serial/sunzilog.c +1
-1@@ -1338,9 +1338,9 @@spin_lock_irqsave (&up->port.lock, flags);for (i =0 ; i < count; i++, s++) { -sunzilog_put_char (channel, *s);if (*s ==10 )sunzilog_put_char (channel,13 ); +sunzilog_put_char (channel, *s); }udelay (2 );spin_unlock_irqrestore (&up->port.lock, flags);diff -ur
linux-2.6.4.orig/drivers/serial/uart00.clinux-2.6.4/drivers/serial/uart00.cdrivers/serial/uart00.c +4
-4@@ -553,16 +553,16 @@* Now, do each character */ for (i =0 ; i < count; i++) { -do { - status =UART_GET_TSR (port); - }while (!UART_TX_READY (status)); -UART_PUT_CHAR (port, s[i]);if (s[i] =='\n' ) {do { status =UART_GET_TSR (port); }while (!UART_TX_READY (status));UART_PUT_CHAR (port,'\r' ); } +do { + status =UART_GET_TSR (port); + }while (!UART_TX_READY (status)); +UART_PUT_CHAR (port, s[i]); }/*
Signature · 1 line
Benjamin Herrenschmidt <[email protected]>
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 2 lines · Andreas Schwab
Some serial console drivers translate LF to CRLF, some do LFCR. This patch changes them to consistently translate to CRLF.
macserial is obsolete (and will be soon removed), please look into pmac zilog rather.
I did.
Quoted 3 lines
Also, why did you move the test for
the transmit buffer empty ? You should at least check there is room in it _before_ writing to it
I did that too.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."