The branch main has been updated by jhb:

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

commit cb5a0eb05310d06e9853a01a542be55b9adee038
Author:     John Baldwin <[email protected]>
AuthorDate: 2026-02-24 20:28:28 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2026-02-24 20:28:28 +0000

    bus: Add a new IVAR accessor to check for the existence of an IVAR
    
    <varp>_has_<var> returns true if the given IVAR can be read.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D55352
---
 sys/sys/bus.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index d90e2a81f054..0d1baaafb4cd 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -945,6 +945,17 @@ DECLARE_MODULE(_name##_##busname, _name##_##busname##_mod, 
        \
  */
 #define __BUS_ACCESSOR(varp, var, ivarp, ivar, type)                   \
                                                                        \
+static __inline bool                                                   \
+varp ## _has_ ## var(device_t dev)                                     \
+{                                                                      \
+       uintptr_t v = 0;                                                \
+       int e;                                                          \
+                                                                       \
+       e = BUS_READ_IVAR(device_get_parent(dev), dev,                  \
+           ivarp ## _IVAR_ ## ivar, &v);                               \
+       return (e == 0);                                                \
+}                                                                      \
+                                                                       \
 static __inline type                                                   \
 varp ## _get_ ## var(device_t dev)                                     \
 {                                                                      \

Reply via email to