mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: bst@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] serial: efi-stdio: fix repeated carriage return with putc callback
Date: Mon, 26 Jan 2026 18:24:14 +0100	[thread overview]
Message-ID: <20260126172458.1761664-1-a.fatoum@pengutronix.de> (raw)

A console driver can populate the console_device::puts callback instead
of having the console core substitute __console_puts, if it can implement
the operation in a more performant manner than the repeated calls to
console_device::putc that occur otherwise.
Whether provided by driver or by console core, console_device::puts
is responsible for converting LF characters to CRLF.

console_device::putc on the other hand does not do any such conversion
and instead its callers are supposed to inject carriage return as needed.

By implementing console_device::putc in terms of console_device::puts for
efi-stdio, putchar('\n') ends up emitting the carriage return twice:
once in the console code and once more in the efi-stdio driver.

Fix this by directly directly calling efi_console_add_char() in the
console_device::getc callback without any line feed handling.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
The cat and readlink tests that are in-flight require this patch, so
the test works correctly for barebox running as EFI payload.
---
 drivers/serial/efi-stdio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index cbeda6f3bb8b..b474fe635d15 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -349,7 +349,9 @@ static int efi_console_puts(struct console_device *cdev, const char *s,
 
 static void efi_console_putc(struct console_device *cdev, char c)
 {
-	efi_console_puts(cdev, &c, 1);
+	struct efi_console_priv *priv = to_efi(cdev);
+	efi_console_add_char(priv, c);
+	efi_console_flush(priv);
 }
 
 static int efi_console_tstc(struct console_device *cdev)
-- 
2.47.3




             reply	other threads:[~2026-01-26 17:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26 17:24 Ahmad Fatoum [this message]
2026-01-27  7:22 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260126172458.1761664-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=bst@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox