stand/libofw: make OF_hasprop() part of the library

Currently it is only needed by powerpc ofwfdt.c, and defined statically
there. Make it available as part of libofw, mirroring what we have in
the kernel.

Two small tweaks are made to the implementation:
  1. Return type is changed to bool
  2. Return 'true' when OF_getproplen() == 0. This matches the expected
     semantics of the kernel version, described in OF_hasprop(9).

Reviewed by:	manu, imp, adrian
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D56429
This commit is contained in:
Mitchell Horne
2026-04-16 14:48:46 -03:00
parent fa77fecb0e
commit 48a05f833c
3 changed files with 8 additions and 6 deletions
+7
View File
@@ -288,6 +288,13 @@ OF_getencprop(phandle_t package, const char *propname, cell_t *buf, int buflen)
return (retval);
}
/* Check existence of a property of a package. */
bool
OF_hasprop(phandle_t node, const char *prop)
{
return (OF_getproplen(node, prop) >= 0);
}
/* Get the next property of a package. */
int
OF_nextprop(phandle_t package, const char *previous, char *buf)
+1
View File
@@ -89,6 +89,7 @@ phandle_t OF_instance_to_package(ihandle_t);
int OF_getproplen(phandle_t, const char *);
int OF_getprop(phandle_t, const char *, void *, int);
int OF_getencprop(phandle_t, const char *, cell_t *, int);
bool OF_hasprop(phandle_t, const char *);
int OF_nextprop(phandle_t, const char *, char *);
int OF_setprop(phandle_t, const char *, void *, int);
int OF_canon(const char *, char *, int);
-6
View File
@@ -32,12 +32,6 @@
extern int command_fdt_internal(int argc, char *argv[]);
static int
OF_hasprop(phandle_t node, const char *prop)
{
return (OF_getproplen(node, (char *)prop) > 0);
}
static void
add_node_to_fdt(void *buffer, phandle_t node, int fdt_offset)
{