Skip to content

Commit 92ad394

Browse files
gmarullcarlescufi
authored andcommitted
device: introduce Z_DEVICE_INIT_ENTRY_DEFINE
Add a new helper macro to define a device init entry. This helps de-cluttering Z_DEVICE_DEFINE. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent f25f552 commit 92ad394

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

include/zephyr/device.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,18 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
973973
Z_DEVICE_INIT(name, pm, data, config, api, state, \
974974
handles)
975975

976+
/**
977+
* @brief Define the init entry for a device.
978+
*
979+
* @param dev_id Device identifier.
980+
* @param init_fn Device init function.
981+
* @param level Initialization level.
982+
* @param prio Initialization priority.
983+
*/
984+
#define Z_DEVICE_INIT_ENTRY_DEFINE(dev_id, init_fn, level, prio) \
985+
Z_INIT_ENTRY_DEFINE(DEVICE_NAME_GET(dev_id), init_fn, \
986+
(&DEVICE_NAME_GET(dev_id)), level, prio)
987+
976988
/**
977989
* @brief Define a struct device and all other required objects.
978990
*
@@ -1004,8 +1016,7 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
10041016
prio, api, state, \
10051017
Z_DEVICE_HANDLE_NAME(node_id, dev_id)); \
10061018
\
1007-
Z_INIT_ENTRY_DEFINE(DEVICE_NAME_GET(dev_id), init_fn, \
1008-
(&DEVICE_NAME_GET(dev_id)), level, prio)
1019+
Z_DEVICE_INIT_ENTRY_DEFINE(dev_id, init_fn, level, prio)
10091020

10101021
#if defined(CONFIG_HAS_DTS) || defined(__DOXYGEN__)
10111022
/**

0 commit comments

Comments
 (0)