wrapper: Treat NULL as root node in devp_offset; add devp_offset_find().
PATCH 2/2 wrapper: Treat NULL as root node in devp_offset; add devp_offset_find().
Many operations, as currently used in the wrapper, assume they can pass NULL and have it be treated as the root node. However, libfdt-wrapper converts NULL to -1, which is only appropriate when searching for nodes, and will cause an error otherwise.
--- arch/powerpc/boot/libfdt-wrapper.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
arch/powerpc/boot/libfdt-wrapper.c +5 -3
@@ -48,7 +48,8 @@check_err (_offset) ?NULL : (void *)(_offset+1 ); \ }) -#define devp_offset (devp) (((int)(devp))-1) +#define devp_offset_find (devp) (((int)(devp))-1) +#define devp_offset (devp) (devp ? ((int)(devp))-1 : 0)static void *fdt;static void *buf;/* = NULL */
@@ -127,8 +128,9 @@ static void *fdt_wrapper_find_node_by_prop_value(const void *prev,const char *val, int len) { - return offset_devp(fdt_node_offset_by_prop_value(fdt, devp_offset(prev), -name ,val ,len )); + int offset = fdt_node_offset_by_prop_value(fdt, devp_offset_find(prev), + name, val, len); +return offset_devp (offset); }static char *fdt_wrapper_get_path (const void *devp,char *buf,int len)
Signature · 1 line
1.5.3.7
Quoted 4 lines · Scott Wood
Many operations, as currently used in the wrapper, assume they can pass NULL and have it be treated as the root node. However, libfdt-wrapper converts NULL to -1, which is only appropriate when searching for nodes, and will cause an error otherwise.
Hrm. AFAICT "many" in this case, means three (being calls to create_node() in devtree.c, main.c and planetcore.c).
Still I guess this patch is ok for now. I futgure I'd like to shrink the wrapper down and make the general interface be as close as possible to the native libfdt interface.
Quoted 1 line
Signed-off-by Scott Wood <[email protected]>
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson