summaryrefslogtreecommitdiffstats
path: root/drivers/base/bus.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-09-20 07:36:44 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-09-23 21:15:13 +0200
commit72b0a6503f8519980a4734bcdbb35a9ec6cd6347 (patch)
tree12513db7ebad9cbe7ad92b0de96922e8bef7b763 /drivers/base/bus.c
parent33a8fa16c68139c50e839f647cc0b34250c75193 (diff)
downloadbarebox-72b0a6503f8519980a4734bcdbb35a9ec6cd6347.tar.gz
barebox-72b0a6503f8519980a4734bcdbb35a9ec6cd6347.tar.xz
driver: register bus
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r--drivers/base/bus.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
new file mode 100644
index 0000000000..f80363d5a7
--- /dev/null
+++ b/drivers/base/bus.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * Under GPLv2
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <errno.h>
+
+LIST_HEAD(bus_list);
+EXPORT_SYMBOL(bus_list);
+
+struct bus_type *get_bus_by_name(const char *name)
+{
+ struct bus_type *bus;
+
+ for_each_bus(bus) {
+ if(!strcmp(bus->name, name))
+ return bus;
+ }
+
+ return NULL;
+}
+
+int bus_register(struct bus_type *bus)
+{
+ if (get_bus_by_name(bus->name))
+ return -EEXIST;
+
+ list_add_tail(&bus->list, &bus_list);
+
+ return 0;
+}