@@ -83,7 +83,7 @@ typedef int16_t device_handle_t;
83
83
* @brief Expands to the name of a global device object.
84
84
*
85
85
* @details Return the full name of a device object symbol created by
86
- * DEVICE_DEFINE(), using the dev_name provided to DEVICE_DEFINE().
86
+ * DEVICE_DEFINE(), using the dev_id provided to DEVICE_DEFINE().
87
87
* This is the name of the global variable storing the device
88
88
* structure, not a pointer to the string in the device's @p name
89
89
* field.
@@ -95,15 +95,15 @@ typedef int16_t device_handle_t;
95
95
* code. In other situations, you are probably looking for
96
96
* device_get_binding().
97
97
*
98
- * @param name The same @p dev_name token given to DEVICE_DEFINE()
98
+ * @param name The same @p dev_id token given to DEVICE_DEFINE()
99
99
*
100
100
* @return The full name of the device object defined by DEVICE_DEFINE()
101
101
*/
102
102
#define DEVICE_NAME_GET (name ) _CONCAT(__device_, name)
103
103
104
104
/* Node paths can exceed the maximum size supported by
105
105
* device_get_binding() in user mode; this macro synthesizes a unique
106
- * dev_name from a devicetree node while staying within this maximum
106
+ * dev_id from a devicetree node while staying within this maximum
107
107
* size.
108
108
*
109
109
* The ordinal used in this name can be mapped to the path by
@@ -121,7 +121,7 @@ typedef int16_t device_handle_t;
121
121
* device from a devicetree node, use DEVICE_DT_DEFINE() or
122
122
* DEVICE_DT_INST_DEFINE() instead.
123
123
*
124
- * @param dev_name A unique token which is used in the name of the
124
+ * @param dev_id A unique token which is used in the name of the
125
125
* global device structure as a C identifier.
126
126
*
127
127
* @param drv_name A string name for the device, which will be stored
@@ -152,13 +152,12 @@ typedef int16_t device_handle_t;
152
152
*
153
153
* @param api_ptr Pointer to the device's API structure. Can be NULL.
154
154
*/
155
- #define DEVICE_DEFINE (dev_name , drv_name , init_fn , pm_device , \
156
- data_ptr , cfg_ptr , level , prio , api_ptr ) \
157
- Z_DEVICE_STATE_DEFINE(DT_INVALID_NODE, dev_name); \
158
- Z_DEVICE_DEFINE(DT_INVALID_NODE, dev_name, drv_name, init_fn, \
159
- pm_device, \
160
- data_ptr, cfg_ptr, level, prio, api_ptr, \
161
- &Z_DEVICE_STATE_NAME(dev_name))
155
+ #define DEVICE_DEFINE (dev_id , drv_name , init_fn , pm_device , data_ptr , cfg_ptr , \
156
+ level , prio , api_ptr ) \
157
+ Z_DEVICE_STATE_DEFINE(DT_INVALID_NODE, dev_id); \
158
+ Z_DEVICE_DEFINE(DT_INVALID_NODE, dev_id, drv_name, init_fn, pm_device, \
159
+ data_ptr, cfg_ptr, level, prio, api_ptr, \
160
+ &Z_DEVICE_STATE_NAME(dev_id))
162
161
163
162
/**
164
163
* @brief Return a string name for a devicetree node.
@@ -215,16 +214,13 @@ typedef int16_t device_handle_t;
215
214
*
216
215
* @param api_ptr Pointer to the device's API structure. Can be NULL.
217
216
*/
218
- #define DEVICE_DT_DEFINE (node_id , init_fn , pm_device , \
219
- data_ptr , cfg_ptr , level , prio , \
220
- api_ptr , ...) \
221
- Z_DEVICE_STATE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id)); \
222
- Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
223
- DEVICE_DT_NAME(node_id), init_fn, \
224
- pm_device, \
225
- data_ptr, cfg_ptr, level, prio, \
226
- api_ptr, \
227
- &Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_NAME(node_id)), \
217
+ #define DEVICE_DT_DEFINE (node_id , init_fn , pm_device , data_ptr , cfg_ptr , level ,\
218
+ prio , api_ptr , ...) \
219
+ Z_DEVICE_STATE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id)); \
220
+ Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
221
+ DEVICE_DT_NAME(node_id), init_fn, pm_device, data_ptr, \
222
+ cfg_ptr, level, prio, api_ptr, \
223
+ &Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_NAME(node_id)), \
228
224
__VA_ARGS__)
229
225
230
226
/**
@@ -348,9 +344,9 @@ typedef int16_t device_handle_t;
348
344
* @brief Obtain a pointer to a device object by name
349
345
*
350
346
* @details Return the address of a device object created by
351
- * DEVICE_DEFINE(), using the dev_name provided to DEVICE_DEFINE().
347
+ * DEVICE_DEFINE(), using the dev_id provided to DEVICE_DEFINE().
352
348
*
353
- * @param name The same as dev_name provided to DEVICE_DEFINE()
349
+ * @param name The same as dev_id provided to DEVICE_DEFINE()
354
350
*
355
351
* @return A pointer to the device object created by DEVICE_DEFINE()
356
352
*/
@@ -384,7 +380,7 @@ typedef int16_t device_handle_t;
384
380
/**
385
381
* @brief Get a <tt>const struct init_entry*</tt> from a device by name
386
382
*
387
- * @param name The same as dev_name provided to DEVICE_DEFINE()
383
+ * @param name The same as dev_id provided to DEVICE_DEFINE()
388
384
*
389
385
* @return A pointer to the init_entry object created for that device
390
386
*/
@@ -804,32 +800,32 @@ static inline bool z_impl_device_is_ready(const struct device *dev)
804
800
805
801
/**
806
802
* @brief Synthesize a unique name for the device state associated with
807
- * dev_name .
803
+ * dev_id .
808
804
*/
809
- #define Z_DEVICE_STATE_NAME (dev_name ) _CONCAT(__devstate_, dev_name )
805
+ #define Z_DEVICE_STATE_NAME (dev_id ) _CONCAT(__devstate_, dev_id )
810
806
811
807
/**
812
808
* @brief Utility macro to define and initialize the device state.
813
809
*
814
810
* @param node_id Devicetree node id of the device.
815
- * @param dev_name Device name .
811
+ * @param dev_id Device identifier .
816
812
*/
817
- #define Z_DEVICE_STATE_DEFINE (node_id , dev_name ) \
818
- static struct device_state Z_DEVICE_STATE_NAME(dev_name ) \
813
+ #define Z_DEVICE_STATE_DEFINE (node_id , dev_id ) \
814
+ static struct device_state Z_DEVICE_STATE_NAME(dev_id ) \
819
815
__attribute__((__section__(".z_devstate")))
820
816
821
817
/**
822
818
* @brief Synthesize the name of the object that holds device ordinal and
823
819
* dependency data.
824
820
*
825
821
* @param node_id Devicetree node id of the device.
826
- * @param dev_name Device name .
822
+ * @param dev_id Device identifier .
827
823
*/
828
- #define Z_DEVICE_HANDLE_NAME (node_id , dev_name ) \
824
+ #define Z_DEVICE_HANDLE_NAME (node_id , dev_id ) \
829
825
_CONCAT(__devicehdl_, \
830
826
COND_CODE_1(DT_NODE_EXISTS(node_id), \
831
827
(node_id), \
832
- (dev_name )))
828
+ (dev_id )))
833
829
834
830
/**
835
831
* @brief Expand extra handles with a comma in between.
@@ -881,14 +877,14 @@ static inline bool z_impl_device_is_ready(const struct device *dev)
881
877
* `gen_handles.py` must be updated.
882
878
*/
883
879
BUILD_ASSERT (sizeof (device_handle_t ) == 2 , "fix the linker scripts" );
884
- #define Z_DEVICE_HANDLES_DEFINE (node_id , dev_name , ...) \
880
+ #define Z_DEVICE_HANDLES_DEFINE (node_id , dev_id , ...) \
885
881
extern Z_DEVICE_HANDLES_CONST device_handle_t \
886
- Z_DEVICE_HANDLE_NAME(node_id, dev_name )[]; \
882
+ Z_DEVICE_HANDLE_NAME(node_id, dev_id )[]; \
887
883
Z_DEVICE_HANDLES_CONST device_handle_t \
888
884
__aligned(sizeof(device_handle_t)) \
889
885
__attribute__((__weak__, \
890
886
__section__(".__device_handles_pass1"))) \
891
- Z_DEVICE_HANDLE_NAME(node_id, dev_name )[] = { \
887
+ Z_DEVICE_HANDLE_NAME(node_id, dev_id )[] = { \
892
888
COND_CODE_1(DT_NODE_EXISTS(node_id), ( \
893
889
DT_DEP_ORD(node_id), \
894
890
DT_REQUIRES_DEP_ORDS(node_id) \
@@ -961,11 +957,11 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
961
957
*
962
958
* @param node_id Devicetree node id for the device (DT_INVALID_NODE if a
963
959
* software device).
964
- * @param dev_name Name of the defined struct device variable .
960
+ * @param dev_id Device identifier (used to name the defined struct device) .
965
961
* @param drv_name Name of the device.
966
962
* @param init_fn Device init function.
967
963
* @param pm_device Reference to struct pm_device associated with the device.
968
- * (optional).
964
+ * (optional).
969
965
* @param data_ptr Reference to device data.
970
966
* @param cfg_ptr Reference to device config.
971
967
* @param level Initialization level.
@@ -974,21 +970,21 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
974
970
* @param state_ptr Reference to device state.
975
971
* @param ... Optional dependencies, manually specified.
976
972
*/
977
- #define Z_DEVICE_DEFINE (node_id , dev_name , drv_name , init_fn , pm_device , \
973
+ #define Z_DEVICE_DEFINE (node_id , dev_id , drv_name , init_fn , pm_device , \
978
974
data_ptr , cfg_ptr , level , prio , api_ptr , state_ptr , \
979
975
...) \
980
- Z_DEVICE_NAME_CHECK(drv_name); \
976
+ Z_DEVICE_NAME_CHECK(name); \
981
977
\
982
- Z_DEVICE_HANDLES_DEFINE(node_id, dev_name , __VA_ARGS__); \
978
+ Z_DEVICE_HANDLES_DEFINE(node_id, dev_id , __VA_ARGS__); \
983
979
\
984
980
COND_CODE_1(DT_NODE_EXISTS(node_id), (), (static)) \
985
- const Z_DECL_ALIGN(struct device) DEVICE_NAME_GET(dev_name) \
986
- Z_DEVICE_SECTION(level, prio) __used = Z_DEVICE_INIT( \
987
- drv_name, pm_device, data_ptr, cfg_ptr, api_ptr, \
988
- state_ptr, Z_DEVICE_HANDLE_NAME(node_id, dev_name )); \
981
+ const Z_DECL_ALIGN(struct device) DEVICE_NAME_GET(dev_id) \
982
+ Z_DEVICE_SECTION(level, prio) __used = \
983
+ Z_DEVICE_INIT(name, pm, data, config, api, state, \
984
+ Z_DEVICE_HANDLE_NAME(node_id, dev_id )); \
989
985
\
990
- Z_INIT_ENTRY_DEFINE(DEVICE_NAME_GET(dev_name ), init_fn, \
991
- (&DEVICE_NAME_GET(dev_name )), level, prio)
986
+ Z_INIT_ENTRY_DEFINE(DEVICE_NAME_GET(dev_id ), init_fn, \
987
+ (&DEVICE_NAME_GET(dev_id )), level, prio)
992
988
993
989
#if defined(CONFIG_HAS_DTS ) || defined(__DOXYGEN__ )
994
990
/**
0 commit comments