[PATCH v1 02/11] stdio: Split out nulldev_register() and move it under #if
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Thu Feb 11 16:09:35 CET 2021
It's possible that NULLDEV can be disabled while it makes leftovers,
move entire device under #if.
Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
---
common/stdio.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/common/stdio.c b/common/stdio.c
index e3e24f0dbf89..2935d0d9ba8a 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -28,6 +28,7 @@ static struct stdio_dev devs;
struct stdio_dev *stdio_devices[] = { NULL, NULL, NULL };
char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
+#if CONFIG_IS_ENABLED(SYS_DEVICE_NULLDEV)
static void nulldev_putc(struct stdio_dev *dev, const char c)
{
/* nulldev is empty! */
@@ -44,6 +45,25 @@ static int nulldev_input(struct stdio_dev *dev)
return 0;
}
+static void nulldev_register(void)
+{
+ struct stdio_dev dev;
+
+ 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;
+
+ stdio_register(&dev);
+}
+#else
+static inline void nulldev_register(void) {}
+#endif /* SYS_DEVICE_NULLDEV */
+
static void stdio_serial_putc(struct stdio_dev *dev, const char c)
{
serial_putc(c);
@@ -83,18 +103,7 @@ static void drv_system_init (void)
dev.tstc = stdio_serial_tstc;
stdio_register (&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;
-
- stdio_register(&dev);
- }
+ nulldev_register();
}
/**************************************************************************
--
2.30.0
More information about the U-Boot
mailing list