diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-12-07 16:42:04 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-12-07 16:42:04 +0100 |
commit | a0643f615d3f54866443050334229c984b83c1b1 (patch) | |
tree | 4ec83e851fdc183099531ff306a225aaa5cd8d13 | |
parent | e5373920525a82339b6818c2b9ffdcce81af2c1b (diff) | |
parent | c2e568d19c5c34a05a1002d25280bf113b72b752 (diff) | |
download | barebox-a0643f615d3f54866443050334229c984b83c1b1.tar.gz barebox-a0643f615d3f54866443050334229c984b83c1b1.tar.xz |
Merge branch 'for-next/driver'
-rw-r--r-- | drivers/base/bus.c | 10 | ||||
-rw-r--r-- | drivers/base/driver.c | 5 | ||||
-rw-r--r-- | include/driver.h | 2 |
3 files changed, 17 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) { diff --git a/include/driver.h b/include/driver.h index f8d815c619..0a5c69eae3 100644 --- a/include/driver.h +++ b/include/driver.h @@ -393,6 +393,8 @@ struct bus_type { int (*probe)(struct device_d *dev); void (*remove)(struct device_d *dev); + struct device_d dev; + struct list_head list; struct list_head device_list; struct list_head driver_list; |