aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-08-11 11:23:37 -0600
committerTom Rini <trini@konsulko.com>2020-08-23 13:43:10 -0400
commit3ca0609adc726ed829325ef6363d6ff5402ea9bb (patch)
tree1d49e9caeb0cb2dacadd4d1d02f2dd067ad63dfd
parent7e15638d609182b651480b1054b60bf40bd0c6fd (diff)
downloadu-boot-3ca0609adc726ed829325ef6363d6ff5402ea9bb.zip
u-boot-3ca0609adc726ed829325ef6363d6ff5402ea9bb.tar.gz
u-boot-3ca0609adc726ed829325ef6363d6ff5402ea9bb.tar.bz2
stdio: Tidy up use of CONFIG_SYS_DEVICE_NULLDEV
Now that this is in Kconfig we can move the logic at the top of the file to Kconfig, and use if() instead of #if. Update the file with these changes. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--common/Kconfig1
-rw-r--r--common/stdio.c30
2 files changed, 11 insertions, 20 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 5a6d0e0..8f61aa7 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -646,6 +646,7 @@ config SPL_SYS_STDIO_DEREGISTER
config SYS_DEVICE_NULLDEV
bool "Enable a null device for stdio"
+ default y if SPLASH_SCREEN || SYS_STDIO_DEREGISTER
help
Enable creation of a "nulldev" stdio device. This allows silent
operation of the console by setting stdout to "nulldev". Enable
diff --git a/common/stdio.c b/common/stdio.c
index 2119204..33a795e 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -31,15 +31,6 @@ static struct stdio_dev devs;
struct stdio_dev *stdio_devices[] = { NULL, NULL, NULL };
char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
-#if defined(CONFIG_SPLASH_SCREEN) && !defined(CONFIG_SYS_DEVICE_NULLDEV)
-#define CONFIG_SYS_DEVICE_NULLDEV 1
-#endif
-
-#if CONFIG_IS_ENABLED(SYS_STDIO_DEREGISTER)
-#define CONFIG_SYS_DEVICE_NULLDEV 1
-#endif
-
-#ifdef CONFIG_SYS_DEVICE_NULLDEV
static void nulldev_putc(struct stdio_dev *dev, const char c)
{
/* nulldev is empty! */
@@ -55,7 +46,6 @@ static int nulldev_input(struct stdio_dev *dev)
/* nulldev is empty! */
return 0;
}
-#endif
static void stdio_serial_putc(struct stdio_dev *dev, const char c)
{
@@ -96,18 +86,18 @@ static void drv_system_init (void)
dev.tstc = stdio_serial_tstc;
stdio_register (&dev);
-#ifdef CONFIG_SYS_DEVICE_NULLDEV
- memset (&dev, 0, sizeof (dev));
+ if (CONFIG_IS_ENABLED(SYS_DEVICE_NULLDEV)) {
+ memset(&dev, '\0', sizeof(dev));
- strcpy (dev.name, "nulldev");
- dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
- dev.putc = nulldev_putc;
- dev.puts = nulldev_puts;
- dev.getc = nulldev_input;
- dev.tstc = nulldev_input;
+ strcpy(dev.name, "nulldev");
+ dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
+ dev.putc = nulldev_putc;
+ dev.puts = nulldev_puts;
+ dev.getc = nulldev_input;
+ dev.tstc = nulldev_input;
- stdio_register (&dev);
-#endif
+ stdio_register(&dev);
+ }
}
/**************************************************************************