[PATCH 3/4] platform_bus: add registrattion to bus
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Tue Aug 16 01:36:06 EDT 2011
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
drivers/base/driver.c | 3 +++
drivers/base/platform.c | 16 ++++++++--------
include/driver.h | 1 +
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index dfd81c5..33eb016 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -120,6 +120,9 @@ int register_device(struct device_d *new_device)
new_device->bus = &platform_bus;
}
+ if (!new_device->parent && new_device->bus == &platform_bus)
+ dev_add_child(&platform_bus_device, new_device);
+
list_add_tail(&new_device->list, &device_list);
INIT_LIST_HEAD(&new_device->children);
INIT_LIST_HEAD(&new_device->cdevs);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index e0dd9ea..60c87d3 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -21,6 +21,7 @@
*/
#include <common.h>
#include <driver.h>
+#include <init.h>
static int platform_match(struct device_d *dev, struct driver_d *drv)
{
@@ -44,15 +45,14 @@ struct bus_type platform_bus = {
.remove = platform_remove,
};
-#if 0
-LIST_HEAD(bus_list);
-EXPORT_SYMBOL(bus_list);
+struct device_d platform_bus_device = {
+ .id = -1,
+ .name = "platform",
+};
-int bus_register(struct bus_type *bus)
+static int platform_bus_init(void)
{
- list_add_tail(&bus->list, &bus_list);
-
+ register_bus_device(&platform_bus_device);
return 0;
}
-#endif
-
+postcore_initcall(platform_bus_init);
diff --git a/include/driver.h b/include/driver.h
index ab7424e..c122cf2 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -370,6 +370,7 @@ struct bus_type {
};
extern struct bus_type platform_bus;
+extern struct device_d platform_bus_device;
struct file_operations {
/*! Called in response of reading from this device. Required */
--
1.7.5.4
More information about the barebox
mailing list