Re: [PATCH v2 08/10] libfdt: Introduce fdt_ptr_offset_
Frank Li <[email protected]> Thu, 4 Jun 2026 17:26:29 -0400
| Newsgroups | org.kernel.vger.devicetree-spec,org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <aiHthWs_EDL63QhE@lizhi-Precision-Tower-5810> |
On Thu, Apr 09, 2026 at 01:54:24PM +0200, Herve Codina wrote: > libfdt provides internal helpers to convert an offset to a pointer but > nothing to do the reverse operation. > > Introduce the fdt_ptr_offset_() internal helper to convert a pointer to > an offset. > > Signed-off-by: Herve Codina <[email protected]> > Reviewed-by: Luca Ceresoli <[email protected]> > --- Reviewed-by: Frank Li <[email protected]> > libfdt/libfdt_internal.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/libfdt/libfdt_internal.h b/libfdt/libfdt_internal.h > index c1ae306..9fd0012 100644 > --- a/libfdt/libfdt_internal.h > +++ b/libfdt/libfdt_internal.h > @@ -47,6 +47,11 @@ static inline void *fdt_offset_ptr_w_(void *fdt, int offset) > return (void *)(uintptr_t)fdt_offset_ptr_(fdt, offset); > } > > +static inline int fdt_ptr_offset_(const void *fdt, const void *ptr) > +{ > + return (const char *)ptr - (const char *)fdt_offset_ptr_(fdt, 0); > +} > + > static inline const struct fdt_reserve_entry *fdt_mem_rsv_(const void *fdt, int n) > { > const struct fdt_reserve_entry *rsv_table = > -- > 2.53.0 >