Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jun 2026 16:28:07 +0000
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 31d52cc42116 - stable/15 - bus: Add a new IVAR accessor to check for the existence of an IVAR
Message-ID:  <6a3ab417.2780c.d4a86ac@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by jhb:

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

commit 31d52cc42116127d7e96826a24881d20d75c512c
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-02-24 20:28:28 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
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)					\
 {									\


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a3ab417.2780c.d4a86ac>