diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2016-07-05 10:26:41 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-08-20 11:35:02 -0400 |
commit | 8e9685715bf78421da48a84040aba3801f66bf47 (patch) | |
tree | 0f5d37f8512180cc93367dbb9a90e2d206ffcb59 /include/libfdt.h | |
parent | 6f5f92c60b7cc86bcfbd4acd310c5efbb6b68a8f (diff) | |
download | u-boot-8e9685715bf78421da48a84040aba3801f66bf47.tar.gz |
libfdt: Add fdt_path_offset_namelen
Add a namelen variant of fdt_path_offset to retrieve the node offset using
only a fixed number of characters.
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Diffstat (limited to 'include/libfdt.h')
-rw-r--r-- | include/libfdt.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/include/libfdt.h b/include/libfdt.h index 4643be5adf..f13b01f08f 100644 --- a/include/libfdt.h +++ b/include/libfdt.h @@ -366,6 +366,17 @@ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name); /** + * fdt_path_offset_namelen - find a tree node based on substring + * @fdt: pointer to the device tree blob + * @path: full path of the node to locate + * @namelen: number of characters of name to consider + * + * Identical to fdt_path_offset(), but only examine the first + * namelen characters of path for matching the node path. + */ +int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen); + +/** * fdt_path_offset - find a tree node by its full path * @fdt: pointer to the device tree blob * @path: full path of the node to locate @@ -387,7 +398,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name); * -FDT_ERR_BADSTRUCTURE, * -FDT_ERR_TRUNCATED, standard meanings. */ -int fdt_path_offset(const void *fdt, const char *path); +static inline int fdt_path_offset(const void *fdt, const char *path) +{ + return fdt_path_offset_namelen(fdt, path, strlen(path)); +} /** * fdt_get_name - retrieve the name of a given node |