summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-09-20 07:36:45 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-09-23 21:15:13 +0200
commited942bc08581b9c6fe6cba0ec8d7601e19d475a2 (patch)
tree58b6299c5b75ddd848dcfa9fb69ca584e4103f29 /drivers/base
parent72b0a6503f8519980a4734bcdbb35a9ec6cd6347 (diff)
downloadbarebox-ed942bc08581b9c6fe6cba0ec8d7601e19d475a2.tar.gz
barebox-ed942bc08581b9c6fe6cba0ec8d7601e19d475a2.tar.xz
driver: search device and driver based on the bus instead of all
This will allow reduce the number of driver and device to search on. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c3
-rw-r--r--drivers/base/driver.c11
2 files changed, 9 insertions, 5 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index f80363d5a7..1dd139f7a3 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -28,6 +28,9 @@ int bus_register(struct bus_type *bus)
if (get_bus_by_name(bus->name))
return -EEXIST;
+ INIT_LIST_HEAD(&bus->device_list);
+ INIT_LIST_HEAD(&bus->driver_list);
+
list_add_tail(&bus->list, &bus_list);
return 0;
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index e3a7bf291c..c55fd23d76 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -85,8 +85,6 @@ static int match(struct driver_d *drv, struct device_d *dev)
dev->driver = drv;
- if (dev->bus != drv->bus)
- goto err_out;
if (dev->bus->match(dev, drv))
goto err_out;
if (dev->bus->probe(dev))
@@ -122,7 +120,7 @@ int register_device(struct device_d *new_device)
if (new_device->bus == &platform_bus && new_device->resource) {
struct device_d *dev;
- for_each_device(dev) {
+ bus_for_each_device(new_device->bus, dev) {
if (!dev->resource)
continue;
if (dev->resource->start == new_device->resource->start) {
@@ -132,12 +130,13 @@ int register_device(struct device_d *new_device)
}
list_add_tail(&new_device->list, &device_list);
+ list_add_tail(&new_device->bus_list, &new_device->bus->device_list);
INIT_LIST_HEAD(&new_device->children);
INIT_LIST_HEAD(&new_device->cdevs);
INIT_LIST_HEAD(&new_device->parameters);
INIT_LIST_HEAD(&new_device->active);
- for_each_driver(drv) {
+ bus_for_each_driver(new_device->bus, drv) {
if (!match(drv, new_device))
break;
}
@@ -169,6 +168,7 @@ int unregister_device(struct device_d *old_dev)
}
list_del(&old_dev->list);
+ list_del(&old_dev->bus_list);
list_del(&old_dev->active);
/* remove device from parents child list */
@@ -222,13 +222,14 @@ int register_driver(struct driver_d *drv)
}
list_add_tail(&drv->list, &driver_list);
+ list_add_tail(&drv->bus_list, &drv->bus->driver_list);
if (!drv->info)
drv->info = noinfo;
if (!drv->shortinfo)
drv->shortinfo = noshortinfo;
- for_each_device(dev)
+ bus_for_each_device(drv->bus, dev)
match(drv, dev);
return 0;