[U-Boot] [PATCH] fdt: prevent clearing memory node if there are no banks

Rob Herring robh at kernel.org
Mon Jun 15 17:57:19 CEST 2015


On Sat, Jun 13, 2015 at 5:43 AM, Andre Przywara <osp at andrep.de> wrote:
> Avoid clearing the reg property in the memory DT node if no memory
> banks have been specified for a board (CONFIG_NR_DRAM_BANKS == 0).
> This allows boards to let U-Boot skip the DT memory tinkering in case
> other firmware has already setup the node properly before.
> This should be safe as all callers of fdt_fixup_memory_banks that use
> a computed <banks> value put at least 1 in there.
> Add some documentation comments to the header file.
>
> Signed-off-by: Andre Przywara <osp at andrep.de>
> ---
> Hi,
>
> this replaces my former "6/8: ARM: bootm: allow skipping fdt memory node fixup"
> patch, as Simon had some (justified) concerns. If this is too generic now,
> let me know and I will rework it.
>
> Cheers,
> Andre.
>
>  common/fdt_support.c  | 14 ++++++++------
>  include/fdt_support.h | 26 ++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 6 deletions(-)
>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 9e50148..6ad532c 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -429,13 +429,15 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
>                 return err;
>         }
>
> -       len = fdt_pack_reg(blob, tmp, start, size, banks);
> +       if (banks) {
> +               len = fdt_pack_reg(blob, tmp, start, size, banks);

Save some indentation:

if (!banks)
  return 0;

>
> -       err = fdt_setprop(blob, nodeoffset, "reg", tmp, len);
> -       if (err < 0) {
> -               printf("WARNING: could not set %s %s.\n",
> -                               "reg", fdt_strerror(err));
> -               return err;
> +               err = fdt_setprop(blob, nodeoffset, "reg", tmp, len);
> +               if (err < 0) {
> +                       printf("WARNING: could not set %s %s.\n",
> +                                       "reg", fdt_strerror(err));
> +                       return err;
> +               }
>         }
>         return 0;
>  }


More information about the U-Boot mailing list