summaryrefslogtreecommitdiff
path: root/common/common_fit.c
diff options
context:
space:
mode:
authorJean-Jacques Hiblot <jjhiblot@ti.com>2017-09-15 12:57:27 +0200
committerTom Rini <trini@konsulko.com>2017-10-05 21:31:04 -0400
commit02035d0086b3f9114463a9b9df38a5618ffe8a04 (patch)
tree24d3ecebfddfb911f4d45cced5713aa2b14f2e35 /common/common_fit.c
parentd56b86eec32a700cdc16170ad8365ee7c6522f0e (diff)
fit: If no matching config is found in fit_find_config_node(), use the default one
If board_fit_config_name_match() doesn't match any configuration node, then use the default one (if provided). Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/common_fit.c')
-rw-r--r--common/common_fit.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/common/common_fit.c b/common/common_fit.c
index 5f5f3f9a44..85b33d8c3b 100644
--- a/common/common_fit.c
+++ b/common/common_fit.c
@@ -32,6 +32,9 @@ int fit_find_config_node(const void *fdt)
{
const char *name;
int conf, node, len;
+ const char *dflt_conf_name;
+ const char *dflt_conf_desc = NULL;
+ int dflt_conf_node = -ENOENT;
conf = fdt_path_offset(fdt, FIT_CONFS_PATH);
if (conf < 0) {
@@ -39,6 +42,9 @@ int fit_find_config_node(const void *fdt)
conf);
return -EINVAL;
}
+
+ dflt_conf_name = fdt_getprop(fdt, conf, "default", &len);
+
for (node = fdt_first_subnode(fdt, conf);
node >= 0;
node = fdt_next_subnode(fdt, node)) {
@@ -50,6 +56,15 @@ int fit_find_config_node(const void *fdt)
#endif
return -EINVAL;
}
+
+ if (dflt_conf_name) {
+ const char *node_name = fdt_get_name(fdt, node, NULL);
+ if (strcmp(dflt_conf_name, node_name) == 0) {
+ dflt_conf_node = node;
+ dflt_conf_desc = name;
+ }
+ }
+
if (board_fit_config_name_match(name))
continue;
@@ -58,5 +73,10 @@ int fit_find_config_node(const void *fdt)
return node;
}
+ if (dflt_conf_node != -ENOENT) {
+ debug("Selecting default config '%s'", dflt_conf_desc);
+ return dflt_conf_node;
+ }
+
return -ENOENT;
}