aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Carriere <etienne.carriere@linaro.org>2018-10-01 08:34:57 +0200
committerJérôme Forissier <jerome.forissier@linaro.org>2018-10-01 09:41:53 +0200
commitdb783ff867d44165bdb5b15f7324c7f5cd754911 (patch)
tree8ecafbb87a62bbd3bc91718deac379dfb344a048
parent439203cb04cee677a6cd8bf9cb02b82d626713cc (diff)
core: correct dt_find_compatible_driver() if no driver found
By convention the compatible array for driver probing ends with a NULL compatible string ID reference. This change ensures such NULL reference is properly handled as the end of the compatible array references. Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
-rw-r--r--core/kernel/dt.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/kernel/dt.c b/core/kernel/dt.c
index 719e97ac..227c4dda 100644
--- a/core/kernel/dt.c
+++ b/core/kernel/dt.c
@@ -17,11 +17,17 @@ const struct dt_driver *dt_find_compatible_driver(const void *fdt, int offs)
const struct dt_device_match *dm;
const struct dt_driver *drv;
- for_each_dt_driver(drv)
- for (dm = drv->match_table; dm; dm++)
+ for_each_dt_driver(drv) {
+ for (dm = drv->match_table; dm; dm++) {
+ if (!dm->compatible) {
+ break;
+ }
if (!fdt_node_check_compatible(fdt, offs,
- dm->compatible))
+ dm->compatible)) {
return drv;
+ }
+ }
+ }
return NULL;
}