diff mbox series

[RESEND,01/16] serial: usbtty: Fix puts function

Message ID 20210205191212.7644-2-pali@kernel.org
State Superseded
Delegated to: Marek Vasut
Headers show
Series Nokia RX-51: Fix USB TTY console and enable it | expand

Commit Message

Pali Rohár Feb. 5, 2021, 7:11 p.m. UTC
This function has incorrect implementation of prepending CR prior LF.
Without this patch it prepended CR prior whole string which is going to be
written and let LF without leading CR. Fix this issue by inserting CR at
correct place to make output on usbtty serial console more readable.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 drivers/serial/usbtty.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Lukasz Majewski Feb. 6, 2021, 1:49 p.m. UTC | #1
On Fri,  5 Feb 2021 20:11:57 +0100
Pali Rohár <pali@kernel.org> wrote:

> This function has incorrect implementation of prepending CR prior LF.
> Without this patch it prepended CR prior whole string which is going
> to be written and let LF without leading CR. Fix this issue by
> inserting CR at correct place to make output on usbtty serial console
> more readable.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> ---
>  drivers/serial/usbtty.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
> index f1c1a260da..02f8edf200 100644
> --- a/drivers/serial/usbtty.c
> +++ b/drivers/serial/usbtty.c
> @@ -500,8 +500,8 @@ void usbtty_puts(struct stdio_dev *dev, const
> char *str) n = next_nl_pos (str);
>  
>  		if (str[n] == '\n') {
> -			__usbtty_puts("\r", 1);
> -			__usbtty_puts(str, n + 1);
> +			__usbtty_puts(str, n);
> +			__usbtty_puts("\r\n", 2);
>  			str += (n + 1);
>  			len -= (n + 1);
>  		} else {

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
diff mbox series

Patch

diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
index f1c1a260da..02f8edf200 100644
--- a/drivers/serial/usbtty.c
+++ b/drivers/serial/usbtty.c
@@ -500,8 +500,8 @@  void usbtty_puts(struct stdio_dev *dev, const char *str)
 		n = next_nl_pos (str);
 
 		if (str[n] == '\n') {
-			__usbtty_puts("\r", 1);
-			__usbtty_puts(str, n + 1);
+			__usbtty_puts(str, n);
+			__usbtty_puts("\r\n", 2);
 			str += (n + 1);
 			len -= (n + 1);
 		} else {