Skip to content

Commit ebe9c23

Browse files
retained_mem: ram: use flexible initialization level
Adjust the initialization level depending if a mutex is used or not. It allows using the drivers pre-kernel for applications that don't use the mutex anyway. Sign-off-by: Dawid Niedzwiecki <dawidn@google.com>
1 parent bf4591b commit ebe9c23

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/retained_mem/retained_mem_zephyr_ram.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ static DEVICE_API(retained_mem, zephyr_retained_mem_ram_api) = {
126126
.clear = zephyr_retained_mem_ram_clear,
127127
};
128128

129+
/* Allow to use the driver PRE_KERNEL if mutexes are disabled. */
130+
#ifdef CONFIG_RETAINED_MEM_MUTEXES
131+
#define RETAINED_MEM_ZEPHYR_RAM_INIT_LVL POST_KERNEL
132+
#else
133+
#define RETAINED_MEM_ZEPHYR_RAM_INIT_LVL PRE_KERNEL_1
134+
#endif
135+
129136
#define ZEPHYR_RETAINED_MEM_RAM_DEVICE(inst) \
130137
IF_ENABLED(CONFIG_RETAINED_MEM_MUTEXES, \
131138
(static struct zephyr_retained_mem_ram_data \
@@ -143,7 +150,7 @@ static DEVICE_API(retained_mem, zephyr_retained_mem_ram_api) = {
143150
(&zephyr_retained_mem_ram_data_##inst), (NULL) \
144151
), \
145152
&zephyr_retained_mem_ram_config_##inst, \
146-
POST_KERNEL, \
153+
RETAINED_MEM_ZEPHYR_RAM_INIT_LVL, \
147154
CONFIG_RETAINED_MEM_INIT_PRIORITY, \
148155
&zephyr_retained_mem_ram_api);
149156

0 commit comments

Comments
 (0)