[U-Boot] [PATCH 1/6] ofnode: Add missing address translation into ofnode_get_addr_size()

Bin Meng bmeng.cn at gmail.com
Tue Sep 25 15:25:25 UTC 2018


Hi Marek,

On Sat, Sep 22, 2018 at 6:59 AM Marek Vasut <marek.vasut at gmail.com> wrote:
>
> Of CONFIG_OF_TRANSLATE is enabled, this function still returns
> untranslated bogus results. Add the missing translation.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Tom Rini <trini at konsulko.com>
> ---
>  drivers/core/ofnode.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
> index a7e1927723..035023ca91 100644
> --- a/drivers/core/ofnode.c
> +++ b/drivers/core/ofnode.c
> @@ -542,8 +542,15 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property,
>                         return FDT_ADDR_T_NONE;
>                 na = of_n_addr_cells(np);
>                 ns = of_n_addr_cells(np);

There is an unrelated bug. It should be:

ns = of_n_size_cells(np);

> +
>                 *sizep = of_read_number(prop + na, ns);
> -               return of_read_number(prop, na);
> +
> +               if (IS_ENABLED(CONFIG_OF_TRANSLATE) && ns > 0) {
> +                       return of_translate_address(ofnode_to_np(node), prop);

Just use np instead of ofnode_to_np(node)

> +               } else {
> +                       na = of_n_addr_cells(ofnode_to_np(node));

This line is unnecessary.

> +                       return of_read_number(prop, na);
> +               }
>         } else {
>                 return fdtdec_get_addr_size(gd->fdt_blob,
>                                             ofnode_to_offset(node), property,
> --

However, I have to point out that this patch (along with the unrelated
bug I pointed out above) is not related to "support parsing PCI
controller DT subnodes". Both of_translate_address() and
of_read_number() are not designed to handle PCI-specific address
formats. See my comments in patch 3 and 5.

Regards,
Bin


More information about the U-Boot mailing list