[RFC PATCH 69/77] libfdt: Introduce fdt_getprop_offset()
From: Herve Codina <herve.codina@bootlin.com>
Date: 2026-01-12 14:22:09
Also in:
lkml
Subsystem:
the rest · Maintainer:
Linus Torvalds
The future support for applying a addon on a base device-tree needs to get an offset to a property based on the node offset and the property name. Several function exists to get a property but none of them allows to get the property offset. Fill the lack and introduce fdt_getprop_offset() Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- libfdt/fdt_ro.c | 12 ++++++++++++ libfdt/libfdt_internal.h | 2 ++ 2 files changed, 14 insertions(+)
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 63494fb..29692f9 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c@@ -508,6 +508,18 @@ const void *fdt_getprop(const void *fdt, int nodeoffset, return fdt_getprop_namelen(fdt, nodeoffset, name, strlen(name), lenp); } +int fdt_getprop_offset(const void *fdt, int nodeoffset, const char *name) +{ + const struct fdt_property *prop; + int lenp, offset; + + prop = fdt_get_property_namelen_(fdt, nodeoffset, name, strlen(name), + &lenp, &offset); + if (!prop) + return lenp; + return offset; +} + uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) { const fdt32_t *php;
diff --git a/libfdt/libfdt_internal.h b/libfdt/libfdt_internal.h
index d80d218..499e821 100644
--- a/libfdt/libfdt_internal.h
+++ b/libfdt/libfdt_internal.h@@ -24,6 +24,8 @@ int32_t fdt_ro_probe_(const void *fdt); int fdt_check_node_offset_(const void *fdt, int offset); int fdt_check_prop_offset_(const void *fdt, int offset); +int fdt_getprop_offset(const void *fdt, int nodeoffset, const char *name); + const char *fdt_find_string_len_(const char *strtab, int tabsize, const char *s, int s_len); static inline const char *fdt_find_string_(const char *strtab, int tabsize,
--
2.52.0