@@ -952,6 +952,30 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
952
952
/**
953
953
* @brief Define a struct device
954
954
*
955
+ * @param node_id Devicetree node id for the device (DT_INVALID_NODE if a
956
+ * software device).
957
+ * @param dev_id Device identifier (used to name the defined struct device).
958
+ * @param name Name of the device.
959
+ * @param pm Reference to struct pm_device associated with the device.
960
+ * (optional).
961
+ * @param data Reference to device data.
962
+ * @param config Reference to device config.
963
+ * @param level Initialization level.
964
+ * @param prio Initialization priority.
965
+ * @param api Reference to device API.
966
+ * @param ... Optional dependencies, manually specified.
967
+ */
968
+ #define Z_DEVICE_BASE_DEFINE (node_id , dev_id , name , pm , data , config , level , \
969
+ prio , api , state , handles ) \
970
+ COND_CODE_1(DT_NODE_EXISTS(node_id), (), (static)) \
971
+ const Z_DECL_ALIGN(struct device) DEVICE_NAME_GET(dev_id) \
972
+ Z_DEVICE_SECTION(level, prio) __used = \
973
+ Z_DEVICE_INIT(name, pm, data, config, api, state, \
974
+ handles)
975
+
976
+ /**
977
+ * @brief Define a struct device and all other required objects.
978
+ *
955
979
* This is the common macro used to define struct device objects. It can be
956
980
* used to define both Devicetree and software devices.
957
981
*
@@ -976,12 +1000,10 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
976
1000
\
977
1001
Z_DEVICE_HANDLES_DEFINE(node_id, dev_id, __VA_ARGS__); \
978
1002
\
979
- COND_CODE_1(DT_NODE_EXISTS(node_id), (), (static)) \
980
- const Z_DECL_ALIGN(struct device) DEVICE_NAME_GET(dev_id) \
981
- Z_DEVICE_SECTION(level, prio) __used = \
982
- Z_DEVICE_INIT(name, pm, data, config, api, state, \
983
- Z_DEVICE_HANDLE_NAME(node_id, dev_id)); \
984
- \
1003
+ Z_DEVICE_BASE_DEFINE(node_id, dev_id, name, pm, data, config, level, \
1004
+ prio, api, state, \
1005
+ Z_DEVICE_HANDLE_NAME(node_id, dev_id)); \
1006
+ \
985
1007
Z_INIT_ENTRY_DEFINE(DEVICE_NAME_GET(dev_id), init_fn, \
986
1008
(&DEVICE_NAME_GET(dev_id)), level, prio)
987
1009
0 commit comments