aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Horne <mhorne@FreeBSD.org>2026-04-16 17:48:46 +0000
committerMitchell Horne <mhorne@FreeBSD.org>2026-04-16 17:50:14 +0000
commit48a05f833c7d0c089d37522cc234039ec823edf4 (patch)
treeab683b446cb0c6a8a87fe424f0b556e737757538
parentfa77fecb0e06ec697e3d7a9ed899e568f1d2090c (diff)
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
-rw-r--r--stand/libofw/openfirm.c7
-rw-r--r--stand/libofw/openfirm.h1
-rw-r--r--stand/powerpc/ofw/ofwfdt.c6
3 files changed, 8 insertions, 6 deletions
diff --git a/stand/libofw/openfirm.c b/stand/libofw/openfirm.c
index 1df65784e47a..ce4444262f6d 100644
--- a/stand/libofw/openfirm.c
+++ b/stand/libofw/openfirm.c
@@ -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)
diff --git a/stand/libofw/openfirm.h b/stand/libofw/openfirm.h
index 35d10c320b57..b4890762b0f9 100644
--- a/stand/libofw/openfirm.h
+++ b/stand/libofw/openfirm.h
@@ -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);
diff --git a/stand/powerpc/ofw/ofwfdt.c b/stand/powerpc/ofw/ofwfdt.c
index eeb5f132a3f2..5422924a3b4c 100644
--- a/stand/powerpc/ofw/ofwfdt.c
+++ b/stand/powerpc/ofw/ofwfdt.c
@@ -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)
{