Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Add slightly-more generalized version of the "of_com...
details: https://anonhg.NetBSD.org/src/rev/ae84b31ec440
branches: trunk
changeset: 319973:ae84b31ec440
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sun Jun 17 15:06:27 2018 +0000
description:
Add slightly-more generalized version of the "of_compat_data" structure
called "device_compatible_entry". It performs a similar function, but
instead of one "compatible" string per entry, it takes an array of
"comaptible" strings per entry. Also included are macros for initializing
an array of these entries and accessing data embedded in them.
diffstat:
sys/sys/device.h | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diffs (39 lines):
diff -r 09b28a8f88ba -r ae84b31ec440 sys/sys/device.h
--- a/sys/sys/device.h Sun Jun 17 14:50:54 2018 +0000
+++ b/sys/sys/device.h Sun Jun 17 15:06:27 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.151 2018/03/04 07:13:11 mlelstv Exp $ */
+/* $NetBSD: device.h,v 1.152 2018/06/17 15:06:27 thorpej Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -123,6 +123,29 @@
typedef struct cfattach *cfattach_t;
#if defined(_KERNEL) || defined(_KMEMUSER)
+struct device_compatible_entry {
+ const char ** dce_compat_strings;
+ union {
+ uintptr_t dceu_val;
+ const void *dceu_ptr;
+ } dce_un;
+};
+#define DEVICE_COMPAT_ENTRY_WITH_DATA(strings, opaque) \
+ { .dce_compat_strings = (strings), \
+ .dce_un.dceu_val = (uintptr_t)(opaque) }
+
+#define DEVICE_COMPAT_ENTRY(strings) \
+ DEVICE_COMPAT_ENTRY_WITH_DATA(strings, 0)
+
+#define DEVICE_COMPAT_TERMINATOR \
+ { .dce_compat_strings = NULL }
+
+#define DEVICE_COMPAT_ENTRY_GET_STRINGS(_dce) ((_dce)->dce_compat_strings)
+#define DEVICE_COMPAT_ENTRY_GET_NUM(_dce) ((_dce)->dce_un.dceu_val)
+#define DEVICE_COMPAT_ENTRY_GET_PTR(_dce) ((_dce)->dce_un.dceu_ptr)
+#define DEVICE_COMPAT_ENTRY_IS_TERMINATOR(_dce) \
+ (((_dce) == NULL || (_dce)->dce_compat_strings == NULL) ? true : false)
+
struct device_lock {
int dvl_nwait;
int dvl_nlock;
Home |
Main Index |
Thread Index |
Old Index