summaryrefslogtreecommitdiff
path: root/zephyr/include/emul/emul_stub_device.h
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/include/emul/emul_stub_device.h')
-rw-r--r--zephyr/include/emul/emul_stub_device.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/zephyr/include/emul/emul_stub_device.h b/zephyr/include/emul/emul_stub_device.h
new file mode 100644
index 0000000000..8eb8a60a28
--- /dev/null
+++ b/zephyr/include/emul/emul_stub_device.h
@@ -0,0 +1,42 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef ZEPHYR_INCLUDE_EMUL_STUB_DEVICE_H_
+#define ZEPHYR_INCLUDE_EMUL_STUB_DEVICE_H_
+
+#include <zephyr/device.h>
+#include <zephyr/devicetree.h>
+
+/*
+ * Needed for emulators without corresponding DEVICE_DT_DEFINE drivers
+ */
+
+struct emul_stub_dev_data {
+ /* Stub */
+};
+struct emul_stub_dev_config {
+ /* Stub */
+};
+struct emul_stub_dev_api {
+ /* Stub */
+};
+
+/* For every instance of a DT_DRV_COMPAT stub out a device for that instance */
+#define EMUL_STUB_DEVICE(n) \
+ __maybe_unused static int emul_init_stub_##n(const struct device *dev) \
+ { \
+ ARG_UNUSED(dev); \
+ return 0; \
+ } \
+ \
+ /* Since this is only stub, allocate the structs once. */ \
+ static struct emul_stub_dev_data stub_data_##n; \
+ static struct emul_stub_dev_config stub_config_##n; \
+ static struct emul_stub_dev_api stub_api_##n; \
+ DEVICE_DT_INST_DEFINE(n, &emul_init_stub_##n, NULL, &stub_data_##n, \
+ &stub_config_##n, POST_KERNEL, 1, \
+ &stub_api_##n);
+
+#endif /* ZEPHYR_INCLUDE_EMUL_STUB_DEVICE_H_ */