The branch stable/15 has been updated by jhb:

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

commit 31d52cc42116127d7e96826a24881d20d75c512c
Author:     John Baldwin <[email protected]>
AuthorDate: 2026-02-24 20:28:28 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2026-06-23 16:00:55 +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
    
    (cherry picked from commit cb5a0eb05310d06e9853a01a542be55b9adee038)
---
 sys/sys/bus.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index 801fd0a1fe51..f1b4e0a7c55c 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -946,6 +946,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