summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-12-07 16:42:04 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-12-07 16:42:04 +0100
commita0643f615d3f54866443050334229c984b83c1b1 (patch)
tree4ec83e851fdc183099531ff306a225aaa5cd8d13 /drivers/base
parente5373920525a82339b6818c2b9ffdcce81af2c1b (diff)
parentc2e568d19c5c34a05a1002d25280bf113b72b752 (diff)
downloadbarebox-a0643f615d3f54866443050334229c984b83c1b1.tar.gz
barebox-a0643f615d3f54866443050334229c984b83c1b1.tar.xz
Merge branch 'for-next/driver'
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c10
-rw-r--r--drivers/base/driver.c5
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 69782d2e7b..e2204da4a4 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -25,9 +25,19 @@ static struct bus_type *get_bus_by_name(const char *name)
int bus_register(struct bus_type *bus)
{
+ int ret;
+
if (get_bus_by_name(bus->name))
return -EEXIST;
+ strcpy(bus->dev.name, bus->name);
+ bus->dev.id = DEVICE_ID_SINGLE;
+
+ ret = register_device(&bus->dev);
+ if (ret)
+ return ret;
+
+
INIT_LIST_HEAD(&bus->device_list);
INIT_LIST_HEAD(&bus->driver_list);
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index dc2df91522..c2e681934f 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -125,6 +125,11 @@ int register_device(struct device_d *new_device)
if (!new_device->bus)
return 0;
+ if (!new_device->parent) {
+ new_device->parent = &new_device->bus->dev;
+ dev_add_child(new_device->parent, new_device);
+ }
+
list_add_tail(&new_device->bus_list, &new_device->bus->device_list);
bus_for_each_driver(new_device->bus, drv) {