[U-Boot] [PATCH 2/2] serial: Make nulldev a serial device
Joe Hershberger
joe.hershberger at ni.com
Thu Nov 1 22:46:28 CET 2012
This allows the default console to be specified as the nulldev. This is
specifically helpful when the real serial console's init() cannot run
early in the boot process. When the init can be run, then the console
can be switched to the real device using the std* env vars.
Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
---
common/stdio.c | 37 -----------------------------------
drivers/serial/serial.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
include/serial.h | 4 ++++
3 files changed, 56 insertions(+), 37 deletions(-)
diff --git a/common/stdio.c b/common/stdio.c
index e9bdc0e..37d36cb 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -40,29 +40,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
-
-
-#ifdef CONFIG_SYS_DEVICE_NULLDEV
-void nulldev_putc(const char c)
-{
- /* nulldev is empty! */
-}
-
-void nulldev_puts(const char *s)
-{
- /* nulldev is empty! */
-}
-
-int nulldev_input(void)
-{
- /* nulldev is empty! */
- return 0;
-}
-#endif
-
/**************************************************************************
* SYSTEM DRIVERS
**************************************************************************
@@ -70,20 +47,6 @@ int nulldev_input(void)
static void drv_system_init (void)
{
-#ifdef CONFIG_SYS_DEVICE_NULLDEV
- struct stdio_dev dev;
-
- memset (&dev, 0, sizeof (dev));
-
- strcpy (dev.name, "nulldev");
- dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
- dev.putc = nulldev_putc;
- dev.puts = nulldev_puts;
- dev.getc = nulldev_input;
- dev.tstc = nulldev_input;
-
- stdio_register (&dev);
-#endif
}
/**************************************************************************
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index f5f43a6..5031b00 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -110,6 +110,57 @@ serial_initfunc(s3c44b0_serial_initialize);
serial_initfunc(sa1100_serial_initialize);
serial_initfunc(sh_serial_initialize);
+#if defined(CONFIG_SPLASH_SCREEN) && !defined(CONFIG_SYS_DEVICE_NULLDEV)
+#define CONFIG_SYS_DEVICE_NULLDEV
+#endif
+
+#if defined(CONFIG_SYS_DEVICE_NULLDEV)
+int nulldev_init(void)
+{
+ /* nulldev is empty! */
+ return 0;
+}
+
+void nulldev_setbrg(void)
+{
+ /* nulldev is empty! */
+}
+
+void nulldev_putc(const char c)
+{
+ /* nulldev is empty! */
+}
+
+void nulldev_puts(const char *s)
+{
+ /* nulldev is empty! */
+}
+
+int nulldev_input(void)
+{
+ /* nulldev is empty! */
+ return 0;
+}
+
+struct serial_device nulldev_serial_device = {
+ "nulldev",
+ nulldev_init,
+ NULL,
+ nulldev_setbrg,
+ nulldev_input,
+ nulldev_input,
+ nulldev_putc,
+ nulldev_puts,
+};
+
+void nulldev_serial_initalize(void)
+{
+ serial_register(&nulldev_serial_device);
+}
+#else
+serial_initfunc(nulldev_serial_initalize);
+#endif
+
/**
* serial_register() - Register serial driver with serial driver core
* @dev: Pointer to the serial driver structure
@@ -154,6 +205,7 @@ void serial_register(struct serial_device *dev)
*/
void serial_initialize(void)
{
+ nulldev_serial_initalize();
mpc8xx_serial_initialize();
ns16550_serial_initialize();
pxa_serial_initialize();
diff --git a/include/serial.h b/include/serial.h
index 14f863e..3d404da 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -22,6 +22,10 @@ struct serial_device {
void default_serial_puts(const char *s);
+#if defined(CONFIG_SYS_DEVICE_NULLDEV)
+extern struct serial_device nulldev_serial_device;
+#endif
+
extern struct serial_device serial_smc_device;
extern struct serial_device serial_scc_device;
extern struct serial_device *default_serial_console(void);
--
1.7.11.5
More information about the U-Boot
mailing list