[PATCH v6 12/22] core: fdtaddr: add devfdt_get_addr_size_index_ptr function

Simon Glass sjg at chromium.org
Mon Mar 6 18:53:17 CET 2023


Hi Johan,

On Thu, 2 Mar 2023 at 17:15, Johan Jonker <jbx6244 at gmail.com> wrote:
>
> Add devfdt_get_addr_size_index_ptr function with the same
> functionality as devfdt_get_addr_size_index, but instead
> a return pointer is given.
>
> Suggested-by: Michael Nazzareno Trimarchi <michael at amarulasolutions.com>
> Signed-off-by: Johan Jonker <jbx6244 at gmail.com>
> Reviewed-by: Michael Trimarchi <michael at amarulasolutions.com>
> ---
>
> Changed V5:
>   fix spelling
>   use tabs
> ---
>  drivers/core/fdtaddr.c |  8 ++++++++
>  include/dm/fdtaddr.h   | 17 ++++++++++++++++-
>  2 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c
> index 91bcd1a2..f5906ff9 100644
> --- a/drivers/core/fdtaddr.c
> +++ b/drivers/core/fdtaddr.c
> @@ -122,6 +122,14 @@ fdt_addr_t devfdt_get_addr_size_index(const struct udevice *dev, int index,
>  #endif
>  }
>
> +void *devfdt_get_addr_size_index_ptr(const struct udevice *dev, int index,
> +                                    fdt_size_t *size)
> +{
> +       fdt_addr_t addr = devfdt_get_addr_size_index(dev, index, size);
> +
> +       return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)(uintptr_t)addr;

Shouldn't this use map_to_sysmem()? We should not cast addresses to pointers.

[..]

Regards,
SImon


More information about the U-Boot mailing list