Skip to content

Commit 1a7ce3f

Browse files
nashifdanieldegrasse
authored andcommitted
Revert "init: Make entry init-function less and introduce service objects"
This reverts commit 175da6b. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
1 parent 7d3a33a commit 1a7ce3f

File tree

6 files changed

+15
-130
lines changed

6 files changed

+15
-130
lines changed

include/zephyr/device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,7 @@ device_get_dt_nodelabels(const struct device *dev)
12631263
static const Z_DECL_ALIGN(struct init_entry) __used __noasan Z_INIT_ENTRY_SECTION( \
12641264
level, prio, Z_DEVICE_INIT_SUB_PRIO(node_id)) \
12651265
Z_INIT_ENTRY_NAME(DEVICE_NAME_GET(dev_id)) = { \
1266+
.init_fn = NULL, \
12661267
.dev = (const struct device *)&DEVICE_NAME_GET(dev_id), \
12671268
}
12681269

include/zephyr/init.h

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

16-
#include <zephyr/service.h>
17-
1816
#ifdef __cplusplus
1917
extern "C" {
2018
#endif
@@ -67,14 +65,15 @@ struct device;
6765
*/
6866
struct init_entry {
6967
/**
70-
* An init entry can be about a device or a service, _init_object
71-
* will be used to differentiate depending on relative sections.
68+
* If the init function belongs to a SYS_INIT, this field stored the
69+
* initialization function, otherwise it is set to NULL.
70+
*/
71+
int (*init_fn)(void);
72+
/**
73+
* If the init entry belongs to a device, this fields stores a
74+
* reference to it, otherwise it is set to NULL.
7275
*/
73-
union {
74-
const void *_init_object;
75-
const struct device *dev;
76-
const struct service *srv;
77-
};
76+
const struct device *dev;
7877
};
7978

8079
/** @cond INTERNAL_HIDDEN */
@@ -165,12 +164,9 @@ struct init_entry {
165164
* @see SYS_INIT()
166165
*/
167166
#define SYS_INIT_NAMED(name, init_fn_, level, prio) \
168-
Z_SERVICE_DEFINE(name, init_fn_, level, prio); \
169167
static const Z_DECL_ALIGN(struct init_entry) \
170168
Z_INIT_ENTRY_SECTION(level, prio, 0) __used __noasan \
171-
Z_INIT_ENTRY_NAME(name) = { \
172-
.srv = (const struct service *)&Z_SERVICE_NAME_GET(name) \
173-
}
169+
Z_INIT_ENTRY_NAME(name) = {.init_fn = (init_fn_), .dev = NULL} \
174170

175171
/** @} */
176172

include/zephyr/linker/common-rom/common-rom-kernel-devices.ld

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
ITERABLE_SECTION_ROM_NUMERIC(device, Z_LINK_ITERABLE_SUBALIGN)
2424

25-
ITERABLE_SECTION_ROM_NUMERIC(service, Z_LINK_ITERABLE_SUBALIGN)
26-
2725
#if defined(CONFIG_GEN_SW_ISR_TABLE) && defined(CONFIG_SHARED_INTERRUPTS)
2826
/* since z_shared_isr() is not referenced anywhere when
2927
* zephyr_pre0.elf is built, the linker will end up dropping it.

include/zephyr/service.h

Lines changed: 0 additions & 92 deletions
This file was deleted.

kernel/init.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ enum init_level {
136136
extern const struct init_entry __init_SMP_start[];
137137
#endif /* CONFIG_SMP */
138138

139-
TYPE_SECTION_START_EXTERN(struct service, service);
140-
TYPE_SECTION_END_EXTERN(struct service, service);
141-
142139
/*
143140
* storage space for the interrupt stack
144141
*
@@ -340,12 +337,6 @@ static int do_device_init(const struct device *dev)
340337
return rc;
341338
}
342339

343-
static inline bool is_entry_about_service(const void *obj)
344-
{
345-
return (obj >= (void *)_service_list_start &&
346-
obj < (void *)_service_list_end);
347-
}
348-
349340
/**
350341
* @brief Execute all the init entry initialization functions at a given level
351342
*
@@ -374,26 +365,17 @@ static void z_sys_init_run_level(enum init_level level)
374365
const struct init_entry *entry;
375366

376367
for (entry = levels[level]; entry < levels[level+1]; entry++) {
368+
const struct device *dev = entry->dev;
377369
int result = 0;
378370

379-
if (unlikely(entry->_init_object == NULL)) {
380-
continue;
381-
}
382-
383371
sys_trace_sys_init_enter(entry, level);
384-
385-
if (is_entry_about_service(entry->_init_object)) {
386-
const struct service *srv = entry->srv;
387-
388-
result = srv->init();
389-
} else {
390-
const struct device *dev = entry->dev;
391-
372+
if (dev != NULL) {
392373
if ((dev->flags & DEVICE_FLAG_INIT_DEFERRED) == 0U) {
393374
result = do_device_init(dev);
394375
}
376+
} else {
377+
result = entry->init_fn();
395378
}
396-
397379
sys_trace_sys_init_exit(entry, level, result);
398380
}
399381
}

subsys/net/lib/sockets/sockets_service.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static K_CONDVAR_DEFINE(wait_start);
2828
STRUCT_SECTION_START_EXTERN(net_socket_service_desc);
2929
STRUCT_SECTION_END_EXTERN(net_socket_service_desc);
3030

31-
static struct service_context {
31+
static struct service {
3232
struct zsock_pollfd events[CONFIG_ZVFS_POLL_MAX];
3333
int count;
3434
} ctx;

0 commit comments

Comments
 (0)