automatically add amba_device as parent of any amba device

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
---
 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


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to