The branch stable/15 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=745c0ea7905789ab0ca1e3f143b7550ce5f7ea91
commit 745c0ea7905789ab0ca1e3f143b7550ce5f7ea91 Author: Mitchell Horne <[email protected]> AuthorDate: 2026-04-16 17:48:46 +0000 Commit: Mitchell Horne <[email protected]> CommitDate: 2026-07-09 17:49:12 +0000 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 (cherry picked from commit 48a05f833c7d0c089d37522cc234039ec823edf4) --- stand/libofw/openfirm.c | 7 +++++++ stand/libofw/openfirm.h | 1 + stand/powerpc/ofw/ofwfdt.c | 6 ------ 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) {
