fix(pm): Use Zephyr created device slots.
* Avoid overwriting random memory by using iterable section created by Zephyr PM.
This commit is contained in:
parent
d0e0ecb4e3
commit
41d81801ed
3 changed files with 3 additions and 16 deletions
|
@ -8,10 +8,6 @@ set(ZEPHYR_EXTRA_MODULES "${ZMK_EXTRA_MODULES};${CMAKE_CURRENT_SOURCE_DIR}/modul
|
||||||
find_package(Zephyr REQUIRED HINTS ../zephyr)
|
find_package(Zephyr REQUIRED HINTS ../zephyr)
|
||||||
project(zmk)
|
project(zmk)
|
||||||
|
|
||||||
if(CONFIG_ZMK_PM_DEVICE_SUSPEND_RESUME)
|
|
||||||
zephyr_linker_sources(SECTIONS include/linker/zmk-pm-devices.ld)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
zephyr_linker_sources(SECTIONS include/linker/zmk-behaviors.ld)
|
zephyr_linker_sources(SECTIONS include/linker/zmk-behaviors.ld)
|
||||||
zephyr_linker_sources(RODATA include/linker/zmk-events.ld)
|
zephyr_linker_sources(RODATA include/linker/zmk-events.ld)
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2023 The ZMK Contributors
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <zephyr/linker/linker-defs.h>
|
|
||||||
|
|
||||||
ITERABLE_SECTION_RAM(zmk_pm_device_slots, 4)
|
|
|
@ -21,7 +21,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||||
// TODO: Tweak this to smarter runtime PM of subsystems on sleep.
|
// TODO: Tweak this to smarter runtime PM of subsystems on sleep.
|
||||||
|
|
||||||
#ifdef CONFIG_ZMK_PM_DEVICE_SUSPEND_RESUME
|
#ifdef CONFIG_ZMK_PM_DEVICE_SUSPEND_RESUME
|
||||||
TYPE_SECTION_START_EXTERN(const struct device *, zmk_pm_device_slots);
|
TYPE_SECTION_START_EXTERN(const struct device *, pm_device_slots);
|
||||||
|
|
||||||
#if !defined(CONFIG_PM_DEVICE_RUNTIME_EXCLUSIVE)
|
#if !defined(CONFIG_PM_DEVICE_RUNTIME_EXCLUSIVE)
|
||||||
/* Number of devices successfully suspended. */
|
/* Number of devices successfully suspended. */
|
||||||
|
@ -57,7 +57,7 @@ int zmk_pm_suspend_devices(void) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPE_SECTION_START(zmk_pm_device_slots)[zmk_num_susp] = dev;
|
TYPE_SECTION_START(pm_device_slots)[zmk_num_susp] = dev;
|
||||||
zmk_num_susp++;
|
zmk_num_susp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ int zmk_pm_suspend_devices(void) {
|
||||||
|
|
||||||
void zmk_pm_resume_devices(void) {
|
void zmk_pm_resume_devices(void) {
|
||||||
for (int i = (zmk_num_susp - 1); i >= 0; i--) {
|
for (int i = (zmk_num_susp - 1); i >= 0; i--) {
|
||||||
pm_device_action_run(TYPE_SECTION_START(zmk_pm_device_slots)[i], PM_DEVICE_ACTION_RESUME);
|
pm_device_action_run(TYPE_SECTION_START(pm_device_slots)[i], PM_DEVICE_ACTION_RESUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
zmk_num_susp = 0;
|
zmk_num_susp = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue