[PATCH v1 06/11] console: Set file and devices at one go

Andy Shevchenko andriy.shevchenko at linux.intel.com
Thu Feb 11 16:09:39 CET 2021


Logical continuation of the change that brought console_devices_set() is
to unify console_setfile() with it and replace in the callers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
---
 common/console.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/common/console.c b/common/console.c
index 4595376dcc0b..672b4a1cc678 100644
--- a/common/console.c
+++ b/common/console.c
@@ -232,7 +232,7 @@ static struct stdio_dev *tstcdev;
 struct stdio_dev **console_devices[MAX_FILES];
 int cd_count[MAX_FILES];
 
-static void __maybe_unused console_devices_set(int file, struct stdio_dev *dev)
+static void console_devices_set(int file, struct stdio_dev *dev)
 {
 	console_devices[file][0] = dev;
 	cd_count[file] = 1;
@@ -369,7 +369,7 @@ static inline void console_doenv(int file, struct stdio_dev *dev)
 #endif
 #else
 
-static void __maybe_unused console_devices_set(int file, struct stdio_dev *dev)
+static void console_devices_set(int file, struct stdio_dev *dev)
 {
 }
 
@@ -417,6 +417,12 @@ static inline void console_doenv(int file, struct stdio_dev *dev)
 #endif
 #endif /* CONIFIG_IS_ENABLED(CONSOLE_MUX) */
 
+static void __maybe_unused console_setfile_and_devices(int file, struct stdio_dev *dev)
+{
+	console_setfile(file, dev);
+	console_devices_set(file, dev);
+}
+
 int console_start(int file, struct stdio_dev *sdev)
 {
 	int error;
@@ -1071,17 +1077,13 @@ int console_init_r(void)
 
 	/* Initializes output console first */
 	if (outputdev != NULL) {
-		console_setfile(stdout, outputdev);
-		console_setfile(stderr, outputdev);
-		console_devices_set(stdout, outputdev);
-		console_devices_set(stderr, outputdev);
+		console_setfile_and_devices(stdout, outputdev);
+		console_setfile_and_devices(stderr, outputdev);
 	}
 
 	/* Initializes input console */
-	if (inputdev != NULL) {
-		console_setfile(stdin, inputdev);
-		console_devices_set(stdin, inputdev);
-	}
+	if (inputdev != NULL)
+		console_setfile_and_devices(stdin, inputdev);
 
 	if (!IS_ENABLED(CONFIG_SYS_CONSOLE_INFO_QUIET))
 		stdio_print_current_devices();
-- 
2.30.0



More information about the U-Boot mailing list