From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 5/7] console: implement console_putc in terms of console_putbin
Date: Mon, 13 Apr 2026 12:09:40 +0200 [thread overview]
Message-ID: <20260413101118.1462119-5-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260413101118.1462119-1-a.fatoum@barebox.org>
console_putc() and console_putbin() both have logic to handle different
stages of console initialization.
Implement the former in terms of the latter to remove the duplication.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
common/console.c | 36 +++++-------------------------------
1 file changed, 5 insertions(+), 31 deletions(-)
diff --git a/common/console.c b/common/console.c
index 014ce2916835..0ce89390864b 100644
--- a/common/console.c
+++ b/common/console.c
@@ -573,40 +573,14 @@ EXPORT_SYMBOL(tstc);
int console_putc(struct console_device *con, char c)
{
- int init = initialized;
bool crlf = c == '\n';
- unsigned int ch;
- ch = console_dev_is_std(con);
- if (!ch) {
- if (crlf)
- con->putc(con, '\r');
- con->putc(con, c);
- }
+ if (crlf)
+ console_putbin(con, "\r\n", 2);
+ else
+ console_putbin(con, &c, 1);
- switch (init) {
- case CONSOLE_UNINITIALIZED:
- console_init_early();
- fallthrough;
- case CONSOLE_INITIALIZED_BUFFER:
- kfifo_putc(console_output_fifo, c);
- if (crlf)
- putc_ll('\r');
- putc_ll(c);
- return 1 + crlf;
-
- case CONSOLE_INIT_FULL:
- for_each_console(cdev) {
- if (cdev->f_active & ch)
- console_putc(cdev, c);
- }
- return 1 + crlf;
- default:
- /* If we have problems inititalizing our data
- * get them early
- */
- hang();
- }
+ return 1 + crlf;
}
EXPORT_SYMBOL(console_putc);
--
2.47.3
next prev parent reply other threads:[~2026-04-13 10:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 10:09 [PATCH 1/7] console: return characters written from console_putc Ahmad Fatoum
2026-04-13 10:09 ` [PATCH 2/7] stddef: implement scoped_var for use in iterators Ahmad Fatoum
2026-04-13 10:09 ` [PATCH 3/7] console: have for_each_console declare the iterator internally Ahmad Fatoum
2026-04-13 10:09 ` [PATCH 4/7] console: make console_puts and friends accept a console_device Ahmad Fatoum
2026-04-13 10:09 ` Ahmad Fatoum [this message]
2026-04-13 10:09 ` [PATCH 6/7] console: implement console_printf Ahmad Fatoum
2026-04-13 10:09 ` [PATCH 7/7] commands: dmesg: give log_print a console_device parameter Ahmad Fatoum
2026-04-13 12:28 ` [PATCH 1/7] console: return characters written from console_putc 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=20260413101118.1462119-5-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/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