summaryrefslogtreecommitdiff
path: root/common/serial.c
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2012-09-12 17:49:58 +0200
committerTom Rini <[email protected]>2012-10-15 11:53:49 -0700
commit2a333aeb8ff4e7b05c47bfaec1816fc2eb8e0198 (patch)
tree2da089ff67c1cf23ebacc9543c158c375ae4a9dd /common/serial.c
parentbfb3127938edf672277ec745e1e2d7d5cad9dbff (diff)
serial: Implement serial_initfunc() macro
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 <[email protected]> Cc: Marek Vasut <[email protected]> Cc: Tom Rini <[email protected]> Cc: Anatolij Gustschin <[email protected]> Cc: Stefan Roese <[email protected]> Cc: Mike Frysinger <[email protected]>
Diffstat (limited to 'common/serial.c')
-rw-r--r--common/serial.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/serial.c b/common/serial.c
index c4b111c496c..7423920b931 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