Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146091090
D55353.id172165.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D55353.id172165.diff
View Options
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -943,7 +943,7 @@
/**
* Generic ivar accessor generation macros for bus drivers
*/
-#define __BUS_ACCESSOR(varp, var, ivarp, ivar, type) \
+#define __BUS_ACCESSOR_COMMON(varp, var, ivarp, ivar, type) \
\
static __inline bool \
varp ## _has_ ## var(device_t dev) \
@@ -956,19 +956,6 @@
return (e == 0); \
} \
\
-static __inline type \
-varp ## _get_ ## var(device_t dev) \
-{ \
- uintptr_t v = 0; \
- int e __diagused; \
- e = BUS_READ_IVAR(device_get_parent(dev), dev, \
- ivarp ## _IVAR_ ## ivar, &v); \
- KASSERT(e == 0, ("%s failed for %s on bus %s, error = %d", \
- __func__, device_get_nameunit(dev), \
- device_get_nameunit(device_get_parent(dev)), e)); \
- return ((type) v); \
-} \
- \
static __inline void \
varp ## _set_ ## var(device_t dev, type t) \
{ \
@@ -981,6 +968,37 @@
device_get_nameunit(device_get_parent(dev)), e)); \
}
+#define __BUS_ACCESSOR(varp, var, ivarp, ivar, type) \
+ __BUS_ACCESSOR_COMMON(varp, var, ivarp, ivar, type) \
+ \
+static __inline type \
+varp ## _get_ ## var(device_t dev) \
+{ \
+ uintptr_t v = 0; \
+ int e __diagused; \
+ \
+ e = BUS_READ_IVAR(device_get_parent(dev), dev, \
+ ivarp ## _IVAR_ ## ivar, &v); \
+ KASSERT(e == 0, ("%s failed for %s on bus %s, error = %d", \
+ __func__, device_get_nameunit(dev), \
+ device_get_nameunit(device_get_parent(dev)), e)); \
+ return ((type) v); \
+}
+
+#define __BUS_ACCESSOR_DEFAULT(varp, var, ivarp, ivar, type, default) \
+ __BUS_ACCESSOR_COMMON(varp, var, ivarp, ivar, type) \
+ \
+static __inline type \
+varp ## _get_ ## 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 ? (type) v : (default)); \
+}
+
struct device_location_cache;
typedef struct device_location_cache device_location_cache_t;
device_location_cache_t *dev_wired_cache_init(void);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 28, 5:53 PM (8 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28883361
Default Alt Text
D55353.id172165.diff (2 KB)
Attached To
Mode
D55353: bus: Add __BUS_ACCESSOR_DEFAULT
Attached
Detach File
Event Timeline
Log In to Comment