Commit 02035d0086b3f9114463a9b9df38a5618ffe8a04

Authored by Jean-Jacques Hiblot
Committed by Tom Rini
1 parent d56b86eec3

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>

Showing 2 changed files with 33 additions and 0 deletions Side-by-side Diff

... ... @@ -32,6 +32,9 @@
32 32 {
33 33 const char *name;
34 34 int conf, node, len;
  35 + const char *dflt_conf_name;
  36 + const char *dflt_conf_desc = NULL;
  37 + int dflt_conf_node = -ENOENT;
35 38  
36 39 conf = fdt_path_offset(fdt, FIT_CONFS_PATH);
37 40 if (conf < 0) {
... ... @@ -39,6 +42,9 @@
39 42 conf);
40 43 return -EINVAL;
41 44 }
  45 +
  46 + dflt_conf_name = fdt_getprop(fdt, conf, "default", &len);
  47 +
42 48 for (node = fdt_first_subnode(fdt, conf);
43 49 node >= 0;
44 50 node = fdt_next_subnode(fdt, node)) {
45 51  
... ... @@ -50,12 +56,26 @@
50 56 #endif
51 57 return -EINVAL;
52 58 }
  59 +
  60 + if (dflt_conf_name) {
  61 + const char *node_name = fdt_get_name(fdt, node, NULL);
  62 + if (strcmp(dflt_conf_name, node_name) == 0) {
  63 + dflt_conf_node = node;
  64 + dflt_conf_desc = name;
  65 + }
  66 + }
  67 +
53 68 if (board_fit_config_name_match(name))
54 69 continue;
55 70  
56 71 debug("Selecting config '%s'", name);
57 72  
58 73 return node;
  74 + }
  75 +
  76 + if (dflt_conf_node != -ENOENT) {
  77 + debug("Selecting default config '%s'", dflt_conf_desc);
  78 + return dflt_conf_node;
59 79 }
60 80  
61 81 return -ENOENT;
... ... @@ -1299,6 +1299,19 @@
1299 1299 #define FDT_ERROR ((ulong)(-1))
1300 1300  
1301 1301 ulong fdt_getprop_u32(const void *fdt, int node, const char *prop);
  1302 +
  1303 +/**
  1304 + * fit_find_config_node() - Find the node for the best DTB in a FIT image
  1305 + *
  1306 + * A FIT image contains one or more DTBs. This function parses the
  1307 + * configurations described in the FIT images and returns the node of
  1308 + * the first matching DTB. To check if a DTB matches a board, this function
  1309 + * calls board_fit_config_name_match(). If no matching DTB is found, it returns
  1310 + * the node described by the default configuration if it exists.
  1311 + *
  1312 + * @fdt: pointer to flat device tree
  1313 + * @return the node if found, -ve otherwise
  1314 + */
1302 1315 int fit_find_config_node(const void *fdt);
1303 1316  
1304 1317 /**