summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2015-12-06 23:52:38 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2015-12-07 10:59:42 +0100
commitcf694d44da75f4aba02e5030fa71e469d2c5acc9 (patch)
tree493220e68a32e4ed605f51bcd21ae40f3660d1d4 /drivers/base
parent87dde1730d2ff31f336e5420b133d9bef9ebeb73 (diff)
downloadbarebox-cf694d44da75f4aba02e5030fa71e469d2c5acc9.tar.gz
barebox-cf694d44da75f4aba02e5030fa71e469d2c5acc9.tar.xz
drivers: bus: Match against id_table first
Matching against driver's name before looking throught its id_table can lead to a somewhat strange and unintuitive behaviour where a device whose driver's name matches one of the lines in id_table (which is not unheard of in Linux kernel) will be probed against said driver with 'id_table' field set to NULL which in turn will result in dev_get_drvdata erroring out with -ENODEV. This patch changes the behaviour such that device_match() only tries to match against driver's name only if id_table of that driver is not present. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 1264e40250..b889a48662 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -54,9 +54,6 @@ int device_match(struct device_d *dev, struct driver_d *drv)
drv->of_compatible)
return of_match(dev, drv);
- if (!strcmp(dev->name, drv->name))
- return 0;
-
if (drv->id_table) {
const struct platform_device_id *id = drv->id_table;
@@ -67,6 +64,8 @@ int device_match(struct device_d *dev, struct driver_d *drv)
}
id++;
}
+ } else if (!strcmp(dev->name, drv->name)) {
+ return 0;
}
return -1;