mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] serial: efi-stdio: fix repeated carriage return with putc callback
@ 2026-01-26 17:24 Ahmad Fatoum
  2026-01-27  7:22 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-01-26 17:24 UTC (permalink / raw)
  To: barebox; +Cc: bst, Ahmad Fatoum

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] serial: efi-stdio: fix repeated carriage return with putc callback
  2026-01-26 17:24 [PATCH] serial: efi-stdio: fix repeated carriage return with putc callback Ahmad Fatoum
@ 2026-01-27  7:22 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-01-27  7:22 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: bst


On Mon, 26 Jan 2026 18:24:14 +0100, Ahmad Fatoum wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] serial: efi-stdio: fix repeated carriage return with putc callback
      https://git.pengutronix.de/cgit/barebox/commit/?id=0c457166c68e (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-27  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-26 17:24 [PATCH] serial: efi-stdio: fix repeated carriage return with putc callback Ahmad Fatoum
2026-01-27  7:22 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox