aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2026-02-24 20:28:28 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2026-02-24 20:28:28 +0000
commitcb5a0eb05310d06e9853a01a542be55b9adee038 (patch)
tree44d5176f76876162eeebe1e6fd4142a65d03f55a
parent82b293ea6987ebcadf1142acd2218f50ab5e3fc8 (diff)
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
-rw-r--r--sys/sys/bus.h11
1 files changed, 11 insertions, 0 deletions
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) \
{ \