[U-Boot] [PATCH v2 6/9] libfdt: Add max phandle retrieval function
Pantelis Antoniou
pantelis.antoniou at konsulko.com
Fri Jun 10 17:13:00 CEST 2016
> On May 27, 2016, at 12:13 , Maxime Ripard <maxime.ripard at free-electrons.com> wrote:
>
> Add a function to retrieve the highest phandle in a given device tree.
>
> Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>
> ---
> include/libfdt.h | 13 +++++++++++++
> lib/libfdt/fdt_ro.c | 15 +++++++++++++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/include/libfdt.h b/include/libfdt.h
> index 4e8eb9ede3a4..1e01b2c7ebdf 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -284,6 +284,19 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
> const char *fdt_string(const void *fdt, int stroffset);
>
> /**
> + * fdt_get_max_phandle - retrieves the highest phandle in a tree
> + * @fdt: pointer to the device tree blob
> + *
> + * fdt_get_max_phandle retrieves the highest phandlle in the given
> + * device tree
> + *
^ typo; phandlle -> phandle
> + * returns:
> + * the highest phandle on success
> + * 0, if an error occured
> + */
> +uint32_t fdt_get_max_phandle(const void *fdt);
> +
> +/**
> * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
> * @fdt: pointer to the device tree blob
> *
> diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
> index 7b0777b67eb3..9130ce718965 100644
> --- a/lib/libfdt/fdt_ro.c
> +++ b/lib/libfdt/fdt_ro.c
> @@ -47,6 +47,21 @@ static int _fdt_string_eq(const void *fdt, int stroffset,
> return (strnlen(p, len + 1) == len) && (memcmp(p, s, len) == 0);
> }
>
> +uint32_t fdt_get_max_phandle(const void *fdt)
> +{
> + uint32_t max_phandle = 0, phandle;
> + int offset;
> +
> + for (offset = fdt_next_node(fdt, -1, NULL); offset >= 0;
> + offset = fdt_next_node(fdt, offset, NULL)) {
> + phandle = fdt_get_phandle(fdt, offset);
> + if (phandle > max_phandle)
> + max_phandle = phandle;
> + }
> +
> + return max_phandle;
> +}
> +
> int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
> {
> FDT_CHECK_HEADER(fdt);
> --
> 2.8.2
>
Regards
— Pantelis
More information about the U-Boot
mailing list