[U-Boot] [PATCH 15/71] serial: ns16550: Move serial registration from serial_initialize()

Marek Vasut marex at denx.de
Mon Sep 17 01:20:40 CEST 2012


Move the registration of eserialN_device ports from default
serial_initialize() into driver specific function called from
serial_initialize(). This slims down the serial_initialize() call
to a bare tracker of all possible serial port registration routines
in U-Boot.

The newly implemented ns16550_serial_initialize() function, which is
implemented inside of the ns16550 serial driver allows encapsulation
of eserialN_device within the ns16550 serial driver itself.

Also, remove the exports of eserialN_device from include/serial.h
as they are no longer needed. This is simply because the implementation of
default_serial_console() is wrapped into the ns16550 serial driver and
the default console is picked by CONFIG_SERIAL<N> macro in config file.

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Marek Vasut <marek.vasut at gmail.com>
Cc: Tom Rini <trini at ti.com>
Cc: Anatolij Gustschin <agust at denx.de>
Cc: Stefan Roese <sr at denx.de>
Cc: Mike Frysinger <vapier at gentoo.org>
Cc: Michal Simek <monstr at monstr.eu>
---
 common/serial.c         |   16 ++--------------
 drivers/serial/serial.c |   16 ++++++++++++++++
 include/serial.h        |    8 ++------
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/common/serial.c b/common/serial.c
index 08c6e2a..faad804 100644
--- a/common/serial.c
+++ b/common/serial.c
@@ -41,6 +41,7 @@ static void serial_null(void)
 		__attribute__((weak, alias("serial_null")));
 
 serial_initfunc(mpc8xx_serial_initialize);
+serial_initfunc(ns16550_serial_initialize);
 serial_initfunc(pxa_serial_initialize);
 serial_initfunc(s3c24xx_serial_initialize);
 serial_initfunc(s5p_serial_initialize);
@@ -65,20 +66,7 @@ void serial_register(struct serial_device *dev)
 void serial_initialize(void)
 {
 	mpc8xx_serial_initialize();
-#if defined(CONFIG_SYS_NS16550_SERIAL)
-#if defined(CONFIG_SYS_NS16550_COM1)
-	serial_register(&eserial1_device);
-#endif
-#if defined(CONFIG_SYS_NS16550_COM2)
-	serial_register(&eserial2_device);
-#endif
-#if defined(CONFIG_SYS_NS16550_COM3)
-	serial_register(&eserial3_device);
-#endif
-#if defined(CONFIG_SYS_NS16550_COM4)
-	serial_register(&eserial4_device);
-#endif
-#endif /* CONFIG_SYS_NS16550_SERIAL */
+	ns16550_serial_initialize();
 	pxa_serial_initialize();
 	s3c24xx_serial_initialize();
 	s5p_serial_initialize();
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index 9d92dee..00ad97c 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -340,4 +340,20 @@ __weak struct serial_device *default_serial_console(void)
 #endif
 }
 
+void ns16550_serial_initialize(void)
+{
+#if defined(CONFIG_SYS_NS16550_COM1)
+	serial_register(&eserial1_device);
+#endif
+#if defined(CONFIG_SYS_NS16550_COM2)
+	serial_register(&eserial2_device);
+#endif
+#if defined(CONFIG_SYS_NS16550_COM3)
+	serial_register(&eserial3_device);
+#endif
+#if defined(CONFIG_SYS_NS16550_COM4)
+	serial_register(&eserial4_device);
+#endif
+}
+
 #endif /* CONFIG_SERIAL_MULTI */
diff --git a/include/serial.h b/include/serial.h
index 497f49a..6a42904 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -33,14 +33,10 @@ extern struct serial_device *default_serial_console(void);
 	defined(CONFIG_TEGRA20) || defined(CONFIG_SYS_COREBOOT)
 extern struct serial_device serial0_device;
 extern struct serial_device serial1_device;
-#if defined(CONFIG_SYS_NS16550_SERIAL)
+#endif
+
 extern struct serial_device eserial1_device;
 extern struct serial_device eserial2_device;
-extern struct serial_device eserial3_device;
-extern struct serial_device eserial4_device;
-#endif /* CONFIG_SYS_NS16550_SERIAL */
-
-#endif
 
 #if defined(CONFIG_OMAP3_ZOOM2)
 extern struct serial_device zoom2_serial_device0;
-- 
1.7.10.4



More information about the U-Boot mailing list