[U-Boot] [PATCH 08/71] serial: Implement serial_initfunc() macro
Marek Vasut
marex at denx.de
Mon Sep 17 01:20:33 CEST 2012
This macro simplifies declaration of weak aliases for per-driver
functions, which register these drivers with the serial subsystem.
The idea here is to push serial_register() calls from serial.c into
the drivers. To avoid pile of ifdef construct as it is now, create
weak aliases to these functions, which in case the driver is not
present alias onto an empty function, which is in turn optimized out
altogether.
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>
---
common/serial.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/common/serial.c b/common/serial.c
index 5740d4f..84dbe50 100644
--- a/common/serial.c
+++ b/common/serial.c
@@ -32,6 +32,14 @@ DECLARE_GLOBAL_DATA_PTR;
static struct serial_device *serial_devices;
static struct serial_device *serial_current;
+static void serial_null(void)
+{
+}
+
+#define serial_initfunc(name) \
+ void name(void) \
+ __attribute__((weak, alias("serial_null")));
+
void serial_register(struct serial_device *dev)
{
#ifdef CONFIG_NEEDS_MANUAL_RELOC
--
1.7.10.4
More information about the U-Boot
mailing list