[U-Boot] [PATCH v3 4/9] fit: If no matching config is found in fit_find_config_node(), use the default one

Simon Glass sjg at chromium.org
Sun Aug 6 05:16:54 UTC 2017


On 4 August 2017 at 11:00, Jean-Jacques Hiblot <jjhiblot at ti.com> wrote:
> 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 at ti.com>
> Reviewed-by: Tom Rini <trini at konsulko.com>
> ---
> changes since v2: Added a comment describing the function fit_find_config_node()
>
>  common/common_fit.c | 20 ++++++++++++++++++++
>  include/image.h     | 13 +++++++++++++
>  2 files changed, 33 insertions(+)

Reviewed-by: Simon Glass <sjg at chromium.org>

See below

>
> diff --git a/common/common_fit.c b/common/common_fit.c
> index 5f5f3f9..85b33d8 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;
>  }
> diff --git a/include/image.h b/include/image.h
> index c6f1513..c981600 100644
> --- a/include/image.h
> +++ b/include/image.h
> @@ -1273,6 +1273,19 @@ void board_fit_image_post_process(void **p_image, size_t *p_size);
>  #define FDT_ERROR      ((ulong)(-1))
>
>  ulong fdt_getprop_u32(const void *fdt, int node, const char *prop);
> +
> +/**
> + * fit_find_config_node() - Find the node for the best DTB in a FIT image
> + *
> + * A FIT image contains one or more DTBs. This functions parses the

function

> + * configurations described in the FIT images and returns the node of
> + * the first matching DTB. To check if a DTB matches a board, this function
> + * calls board_fit_config_name_match(). If no matching DTB is found, it returns
> + * the node described by the default configuration if it exits.

exists

> + *
> + * @fdt: pointer to flat device tree
> + * @return the node if found, -ev otherwise

-ve

> + */
>  int fit_find_config_node(const void *fdt);
>
>  /**
> --
> 1.9.1
>


More information about the U-Boot mailing list