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 <[email protected]>
---
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