Skip to content

Commit 040da09

Browse files
committed
init: Adapt init entry section generation
The sub-prio is entirely removed, as the new macros will bring uniquely computed priorities. This is seamless: none of this is of public API, so no deprecation and macro replacement is necessary at this stage. Signed-off-by: Tomasz Bursztyka <[email protected]>
1 parent e4af5ac commit 040da09

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

include/zephyr/device.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -982,17 +982,6 @@ device_get_dt_nodelabels(const struct device *dev)
982982
};
983983
#endif /* CONFIG_DEVICE_DT_METADATA */
984984

985-
/**
986-
* @brief Init sub-priority of the device
987-
*
988-
* The sub-priority is defined by the devicetree ordinal, which ensures that
989-
* multiple drivers running at the same priority level run in an order that
990-
* respects the devicetree dependencies.
991-
*/
992-
#define Z_DEVICE_INIT_SUB_PRIO(node_id) \
993-
COND_CODE_1(DT_NODE_EXISTS(node_id), \
994-
(DT_DEP_ORD_STR_SORTABLE(node_id)), (0))
995-
996985
/**
997986
* @brief Maximum device name length.
998987
*
@@ -1109,7 +1098,7 @@ device_get_dt_nodelabels(const struct device *dev)
11091098
Z_DEVICE_CHECK_INIT_LEVEL(level) \
11101099
\
11111100
static const Z_DECL_ALIGN(struct init_entry) __used __noasan Z_INIT_ENTRY_SECTION( \
1112-
level, prio, Z_DEVICE_INIT_SUB_PRIO(node_id)) \
1101+
level, prio) \
11131102
Z_INIT_ENTRY_NAME(DEVICE_NAME_GET(dev_id)) = { \
11141103
.init_fn = {COND_CODE_1(Z_DEVICE_IS_MUTABLE(node_id), (.dev_rw), (.dev)) = \
11151104
(init_fn_)}, \

include/zephyr/init.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <zephyr/sys/util.h>
1414
#include <zephyr/toolchain.h>
1515

16+
#include <zephyr/sys/util_init.h>
17+
1618
#ifdef __cplusplus
1719
extern "C" {
1820
#endif
@@ -144,12 +146,10 @@ struct init_entry {
144146
* @brief Init entry section.
145147
*
146148
* Each init entry is placed in a section with a name crafted so that it allows
147-
* linker scripts to sort them according to the specified
148-
* level/priority/sub-priority.
149+
* linker scripts to sort them according to the specified level and priority.
149150
*/
150-
#define Z_INIT_ENTRY_SECTION(level, prio, sub_prio) \
151-
__attribute__((__section__( \
152-
".z_init_" #level STRINGIFY(prio)"_" STRINGIFY(sub_prio)"_")))
151+
#define Z_INIT_ENTRY_SECTION(level, prio) \
152+
__attribute__((__section__(".z_init_" #level STRINGIFY(prio)"_")))
153153

154154

155155
/* Designated initializers where added to C in C99. There were added to
@@ -235,10 +235,10 @@ struct init_entry {
235235
*
236236
* @see SYS_INIT()
237237
*/
238-
#define SYS_INIT_NAMED(name, init_fn_, level, prio) \
239-
static const Z_DECL_ALIGN(struct init_entry) \
240-
Z_INIT_ENTRY_SECTION(level, prio, 0) __used __noasan \
241-
Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)}, \
238+
#define SYS_INIT_NAMED(name, init_fn_, level, prio) \
239+
static const Z_DECL_ALIGN(struct init_entry) \
240+
Z_INIT_ENTRY_SECTION(level, prio) __used __noasan \
241+
Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)}, \
242242
Z_INIT_SYS_INIT_DEV_NULL}
243243

244244
/** @} */

0 commit comments

Comments
 (0)