[Concept,10/13] console: Shorten the console-error-output function names

Message ID 20260204001002.2638622-11-sjg@u-boot.org
State New
Headers
Series Add putsn() for length-based console output |

Commit Message

Simon Glass Feb. 4, 2026, 12:09 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

The current names are quite verbose.

Rename console_puts_select_stderr() to err_puts() and
console_printf_select_stderr() to err_printf()

Co-developed-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 common/console.c                  |  6 +++---
 drivers/video/console_truetype.c  |  6 ++----
 drivers/video/vidconsole-uclass.c | 21 ++++++++++-----------
 include/console.h                 |  8 ++++----
 4 files changed, 19 insertions(+), 22 deletions(-)
  

Patch

diff --git a/common/console.c b/common/console.c
index fbf2c875428..f9669a0e028 100644
--- a/common/console.c
+++ b/common/console.c
@@ -311,13 +311,13 @@  static void console_puts_select(int file, bool serial_only, const char *s)
 	}
 }
 
-void console_puts_select_stderr(bool serial_only, const char *s)
+void err_puts(bool serial_only, const char *s)
 {
 	if (gd->flags & GD_FLG_DEVINIT)
 		console_puts_select(stderr, serial_only, s);
 }
 
-int console_printf_select_stderr(bool serial_only, const char *fmt, ...)
+int err_printf(bool serial_only, const char *fmt, ...)
 {
 	char buf[CONFIG_SYS_PBSIZE];
 	va_list args;
@@ -330,7 +330,7 @@  int console_printf_select_stderr(bool serial_only, const char *fmt, ...)
 	 */
 	ret = vscnprintf(buf, sizeof(buf), fmt, args);
 	va_end(args);
-	console_puts_select_stderr(serial_only, buf);
+	err_puts(serial_only, buf);
 
 	return ret;
 }
diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 25df22e31b0..913ed4208e4 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -441,14 +441,12 @@  static int console_truetype_putc_xy(struct udevice *dev, void *vctx, uint x,
 			last_cp = pos->cp;
 		kern = stbtt_GetCodepointKernAdvance(font, last_cp, cp);
 		if (_DEBUG) {
-			console_printf_select_stderr(true, "kern %c (%02x)",
-						     last_cp, last_cp);
+			err_printf(true, "kern %c (%02x)", last_cp, last_cp);
 		}
 		xpos += met->scale * kern;
 	}
 	if (_DEBUG) {
-		console_printf_select_stderr(true, " %c (%02x)\n",
-					     cp >= ' ' ? cp : ' ', cp);
+		err_printf(true, " %c (%02x)\n", cp >= ' ' ? cp : ' ', cp);
 	}
 
 	/*
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 3d440e8e672..fc2b443d0bd 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -122,7 +122,7 @@  static void vidconsole_newline(struct udevice *dev, struct vidconsole_ctx *ctx)
 	ret = video_sync(dev->parent, false);
 	if (ret) {
 #ifdef DEBUG
-		console_puts_select_stderr(true, "[vc err: video_sync]");
+		err_puts(true, "[vc err: video_sync]");
 #endif
 	}
 }
@@ -333,7 +333,7 @@  static void vidconsole_escape_char(struct udevice *dev,
 			ret = video_sync(dev->parent, false);
 			if (ret) {
 #ifdef DEBUG
-				console_puts_select_stderr(true, "[vc err: video_sync]");
+				err_puts(true, "[vc err: video_sync]");
 #endif
 			}
 			ctx->ycur = 0;
@@ -460,11 +460,10 @@  static int vidconsole_output_glyph(struct udevice *dev,
 {
 	int ret;
 
-	if (_DEBUG) {
-		console_printf_select_stderr(true,
-				     "glyph last_ch '%c': ch '%c' (%02x): ",
-				     ctx->last_ch, ch >= ' ' ? ch : ' ', ch);
-	}
+	if (_DEBUG)
+		err_printf(true, "glyph last_ch '%c': ch '%c' (%02x): ",
+			   ctx->last_ch, ch >= ' ' ? ch : ' ', ch);
+
 	/*
 	 * Failure of this function normally indicates an unsupported
 	 * colour depth. Check this and return an error to help with
@@ -578,13 +577,13 @@  static void vidconsole_putc(struct stdio_dev *sdev, const char ch)
 	ret = vidconsole_put_char(dev, NULL, ch);
 	if (ret) {
 #ifdef DEBUG
-		console_puts_select_stderr(true, "[vc err: putc]");
+		err_puts(true, "[vc err: putc]");
 #endif
 	}
 	ret = video_sync(dev->parent, false);
 	if (ret) {
 #ifdef DEBUG
-		console_puts_select_stderr(true, "[vc err: video_sync]");
+		err_puts(true, "[vc err: video_sync]");
 #endif
 	}
 }
@@ -603,13 +602,13 @@  static void vidconsole_putsn(struct stdio_dev *sdev, const char *s, int len)
 		char str[30];
 
 		snprintf(str, sizeof(str), "[vc err: putsn %d]", ret);
-		console_puts_select_stderr(true, str);
+		err_puts(true, str);
 #endif
 	}
 	ret = video_sync(dev->parent, false);
 	if (ret) {
 #ifdef DEBUG
-		console_puts_select_stderr(true, "[vc err: video_sync]");
+		err_puts(true, "[vc err: video_sync]");
 #endif
 	}
 }
diff --git a/include/console.h b/include/console.h
index 209b67f3535..83b8d4f642c 100644
--- a/include/console.h
+++ b/include/console.h
@@ -159,7 +159,7 @@  static inline bool console_record_isempty(void)
 int console_announce_r(void);
 
 /**
- * console_puts_select_stderr() - Output a string to selected console devices
+ * err_puts() - Output a string to selected console devices
  *
  * This writes to stderr only. It is useful for outputting errors
  *
@@ -167,10 +167,10 @@  int console_announce_r(void);
  *	else
  * @s: String to output
  */
-void console_puts_select_stderr(bool serial_only, const char *s);
+void err_puts(bool serial_only, const char *s);
 
 /**
- * console_printf_select_stderr() - Output a formatted string to selected devs
+ * err_printf() - Output a formatted string to selected devs
  *
  * This writes to stderr only. It is useful for outputting errors. Note that it
  * uses its own buffer, separate from the print buffer, to allow printing
@@ -181,7 +181,7 @@  void console_puts_select_stderr(bool serial_only, const char *s);
  * @fmt: Printf format string, followed by format arguments
  * Return: number of characters written
  */
-int console_printf_select_stderr(bool serial_only, const char *fmt, ...)
+int err_printf(bool serial_only, const char *fmt, ...)
 		__attribute__ ((format (__printf__, 2, 3)));
 
 /**