[U-Boot] [PATCH v2 2/9] fdt_support: refactor with fdt_find_or_add_subnode helper func

Simon Glass sjg at chromium.org
Sat May 24 03:18:04 CEST 2014


Hi Masahiro,

On 17 April 2014 22:40, Masahiro Yamada <yamada.m at jp.panasonic.com> wrote:
> Some functions in fdt_support.c do the same routine:
> search a node with a given name ("chosen", "memory", etc.)
> or newly create it if it does not exist.
>
> So this commit makes that routine to a helper function.
>
> Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
> ---
>
> Changes in v2: None
>
>  common/fdt_support.c | 71 ++++++++++++++++++++++++++--------------------------
>  1 file changed, 36 insertions(+), 35 deletions(-)
>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 2464847..849bdc8 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
[snip]
> @@ -160,14 +185,10 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force)
>         const char *path;
>         uint64_t addr, size;
>
> -       /* Find the "chosen" node.  */
> -       nodeoffset = fdt_path_offset (fdt, "/chosen");
> -
> -       /* If there is no "chosen" node in the blob return */
> -       if (nodeoffset < 0) {
> -               printf("fdt_initrd: %s\n", fdt_strerror(nodeoffset));
> +       /* find or create "/chosen" node. */
> +       nodeoffset = fdt_find_or_add_subnode(fdt, 0, "chosen");
> +       if (nodeoffset < 0)

It looks like you are changing the behaviour here, but I think that is
fine. We should create it if it is missing.

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

Regards,
Simon


More information about the U-Boot mailing list