diff options
author | Peter Johanson <[email protected]> | 2024-03-25 09:37:14 +0000 |
---|---|---|
committer | Pete Johanson <[email protected]> | 2024-03-27 20:59:26 -0700 |
commit | 41d81801ed11a1dca918c9c0088351856e4e1808 (patch) | |
tree | 6db4e8ae826ff71fe212613bd37b5b17be443d06 | |
parent | d0e0ecb4e3d11b5303c1dc5c857ff1f75c1d0aaa (diff) | |
download | zmk-41d81801ed11a1dca918c9c0088351856e4e1808.tar.gz zmk-41d81801ed11a1dca918c9c0088351856e4e1808.zip |
fix(pm): Use Zephyr created device slots.
* Avoid overwriting random memory by using
iterable section created by Zephyr PM.
-rw-r--r-- | app/CMakeLists.txt | 4 | ||||
-rw-r--r-- | app/include/linker/zmk-pm-devices.ld | 9 | ||||
-rw-r--r-- | app/src/pm.c | 6 |
3 files changed, 3 insertions, 16 deletions
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 2744f53d59..0b681ea953 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -8,10 +8,6 @@ set(ZEPHYR_EXTRA_MODULES "${ZMK_EXTRA_MODULES};${CMAKE_CURRENT_SOURCE_DIR}/modul find_package(Zephyr REQUIRED HINTS ../zephyr) 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(RODATA include/linker/zmk-events.ld) diff --git a/app/include/linker/zmk-pm-devices.ld b/app/include/linker/zmk-pm-devices.ld deleted file mode 100644 index 93ec5025de..0000000000 --- a/app/include/linker/zmk-pm-devices.ld +++ /dev/null @@ -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) diff --git a/app/src/pm.c b/app/src/pm.c index 4f151875ba..447eb351c9 100644 --- a/app/src/pm.c +++ b/app/src/pm.c @@ -21,7 +21,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); // TODO: Tweak this to smarter runtime PM of subsystems on sleep. #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) /* Number of devices successfully suspended. */ @@ -57,7 +57,7 @@ int zmk_pm_suspend_devices(void) { 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++; } @@ -66,7 +66,7 @@ int zmk_pm_suspend_devices(void) { void zmk_pm_resume_devices(void) { 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; |