mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 7/7] commands: dmesg: give log_print a console_device parameter
Date: Mon, 13 Apr 2026 12:09:42 +0200	[thread overview]
Message-ID: <20260413101118.1462119-7-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260413101118.1462119-1-a.fatoum@barebox.org>

log_print currently prints out unconditionally to stdout and thus has no
support for printing to a single specific console, e.g. the framebuffer
console.

Make use of the new console_printf() to address this.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 commands/dmesg.c        |  2 +-
 common/console_common.c | 17 +++++++++--------
 include/linux/printk.h  |  3 ++-
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/commands/dmesg.c b/commands/dmesg.c
index 0313c8cdea74..06796287aaec 100644
--- a/commands/dmesg.c
+++ b/commands/dmesg.c
@@ -158,7 +158,7 @@ static int do_dmesg(int argc, char *argv[])
 		return 0;
 	}
 
-	ret = log_print(flags, levels);
+	ret = log_print(CONSOLE_DEV_STDOUT, flags, levels);
 	if (ret)
 		return 1;
 
diff --git a/common/console_common.c b/common/console_common.c
index 310534affa58..de0a213f833c 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -215,13 +215,14 @@ int log_writefile(const char *filepath)
 /**
  * log_print - print the log buffer
  *
+ * @con:	Console device to print to
  * @flags:	Flags selecting output formatting
  * @levels:	bitmask of loglevels to print, 0 for all
  *
  * This function prints the messages of the selected levels; optionally with
  * additional information and formatting.
  */
-int log_print(unsigned flags, unsigned levels)
+int log_print(struct console_device *con, unsigned flags, unsigned levels)
 {
 	struct log_entry *log;
 	unsigned long last = 0;
@@ -237,30 +238,30 @@ int log_print(unsigned flags, unsigned levels)
 
 		if (!(flags & (BAREBOX_LOG_PRINT_RAW | BAREBOX_LOG_PRINT_TIME
 			       | BAREBOX_LOG_DIFF_TIME)))
-			print_colored_log_level(CONSOLE_DEV_STDOUT, log->level);
+			print_colored_log_level(con, log->level);
 
 		if (flags & BAREBOX_LOG_PRINT_RAW)
-			printf("<%i>", log->level);
+			console_printf(con, "<%i>", log->level);
 
 		/* convert ns to us */
 		do_div(time_ns, 1000);
 		time = time_ns;
 
 		if (flags & (BAREBOX_LOG_PRINT_TIME | BAREBOX_LOG_DIFF_TIME))
-			printf("[");
+			console_printf(con, "[");
 
 		if (flags & BAREBOX_LOG_PRINT_TIME)
-			printf("%10luus", time);
+			console_printf(con, "%10luus", time);
 
 		if (flags & BAREBOX_LOG_DIFF_TIME) {
-			printf(" < %10luus", time - last);
+			console_printf(con, " < %10luus", time - last);
 			last = time;
 		}
 
 		if (flags & (BAREBOX_LOG_PRINT_TIME | BAREBOX_LOG_DIFF_TIME))
-			printf("] ");
+			console_printf(con, "] ");
 
-		printf("%s", log->msg);
+		console_printf(con, "%s", log->msg);
 	}
 
 	return 0;
diff --git a/include/linux/printk.h b/include/linux/printk.h
index deaaa44b31a7..4d6df821e1f1 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -192,7 +192,8 @@ extern void log_clean(unsigned int limit);
 #define BAREBOX_LOG_PRINT_TIME		BIT(0)
 
 int log_writefile(const char *filepath);
-int log_print(unsigned flags, unsigned levels);
+struct console_device;
+int log_print(struct console_device *console, unsigned flags, unsigned levels);
 
 struct va_format {
 	const char *fmt;
-- 
2.47.3




  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 ` [PATCH 5/7] console: implement console_putc in terms of console_putbin Ahmad Fatoum
2026-04-13 10:09 ` [PATCH 6/7] console: implement console_printf Ahmad Fatoum
2026-04-13 10:09 ` Ahmad Fatoum [this message]
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-7-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