[PATCH v5 12/21] core: read: add dev_read_addr_index_ptr function

Simon Glass sjg at chromium.org
Wed Mar 1 16:01:47 CET 2023


Hi Johan,

On Tue, 28 Feb 2023 at 14:20, Johan Jonker <jbx6244 at gmail.com> wrote:
>
> Add dev_read_addr_index_ptr function with the same
> functionality as dev_read_addr_index, but instead
> a return pointer is given.
>
> Signed-off-by: Johan Jonker <jbx6244 at gmail.com>
> ---
>
> Changed V5:
>   new patch
> ---
>  drivers/core/read.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/core/read.c b/drivers/core/read.c
> index e0543bba..85c46913 100644
> --- a/drivers/core/read.c
> +++ b/drivers/core/read.c
> @@ -131,6 +131,13 @@ fdt_addr_t dev_read_addr_index(const struct udevice *dev, int index)
>                 return devfdt_get_addr_index(dev, index);
>  }
>
> +void *dev_read_addr_index_ptr(const struct udevice *dev, int index)
> +{
> +       fdt_addr_t addr = dev_read_addr_index(dev, index);
> +
> +       return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)(uintptr_t)addr;

Please use map_sysmem() rather than a cast, so it can be used on sandbox.

> +}
> +
>  fdt_addr_t dev_read_addr_size_index(const struct udevice *dev, int index,
>                                     fdt_size_t *size)
>  {
> --
> 2.20.1
>

Regards,
Simon


More information about the U-Boot mailing list