diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2026-02-24 20:28:28 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2026-02-24 20:28:28 +0000 |
| commit | cb5a0eb05310d06e9853a01a542be55b9adee038 (patch) | |
| tree | 44d5176f76876162eeebe1e6fd4142a65d03f55a | |
| parent | 82b293ea6987ebcadf1142acd2218f50ab5e3fc8 (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.h | 11 |
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) \ { \ |
