Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Apr 2026 17:50:25 +0000
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 48a05f833c7d - main - stand/libofw: make OF_hasprop() part of the library
Message-ID:  <69e12161.375b1.47fbd670@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=48a05f833c7d0c089d37522cc234039ec823edf4

commit 48a05f833c7d0c089d37522cc234039ec823edf4
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2026-04-16 17:48:46 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-04-16 17:50:14 +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
---
 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)
 {


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e12161.375b1.47fbd670>