[PATCH 03/12] amba: add bus device
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Sun Oct 14 17:01:09 EDT 2012
automatically add amba_device as parent of any amba device
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
drivers/amba/bus.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index f0a40b6..581a25c 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -72,6 +72,11 @@ static void amba_remove(struct device_d *dev)
drv->remove(pcdev);
}
+struct device_d amba_bus = {
+ .name = "amba",
+ .id = DEVICE_ID_SINGLE,
+};
+
struct bus_type amba_bustype = {
.name = "amba",
.match = amba_match,
@@ -153,6 +158,8 @@ int amba_device_add(struct amba_device *dev)
goto err_release;
skip_probe:
+ dev->dev.parent = &amba_bus;
+ dev_add_child(dev->dev.parent, &dev->dev);
ret = register_device(&dev->dev);
if (ret)
goto err_release;
@@ -212,6 +219,7 @@ struct amba_device *amba_device_alloc(const char *name, int id, resource_size_t
static int amba_bus_init(void)
{
+ register_device(&amba_bus);
return bus_register(&amba_bustype);
}
pure_initcall(amba_bus_init);
--
1.7.10.4
More information about the barebox
mailing list