From f7437ac3b1a35fae56b810bbaf0bca06e4a91e18 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Mon, 29 Apr 2024 10:49:22 -0700 Subject: [PATCH] pm: Move z_pm_save_idle_exit to pm subsys There is no need to this function be defined inside the kernel since all places using it are protecting the call under ifdef PM guards. This way we can also remove the ifdef condition inside the implementation. Signed-off-by: Flavio Ceolin --- include/zephyr/pm/pm.h | 9 +++++++-- kernel/idle.c | 15 --------------- subsys/pm/pm.c | 13 +++++++++++++ 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/include/zephyr/pm/pm.h b/include/zephyr/pm/pm.h index 09138bf1871..5c552947221 100644 --- a/include/zephyr/pm/pm.h +++ b/include/zephyr/pm/pm.h @@ -116,6 +116,10 @@ int pm_notifier_unregister(struct pm_notifier *notifier); */ const struct pm_state_info *pm_state_next_get(uint8_t cpu); +/** @cond INTERNAL_HIDDEN */ +void z_pm_save_idle_exit(void); +/** @endcond */ + /** * @} */ @@ -175,10 +179,11 @@ static inline const struct pm_state_info *pm_state_next_get(uint8_t cpu) return NULL; } +static inline void z_pm_save_idle_exit(void) +{ +} #endif /* CONFIG_PM */ -void z_pm_save_idle_exit(void); - #ifdef __cplusplus } #endif diff --git a/kernel/idle.c b/kernel/idle.c index bef193aa8e8..62ff84e4c88 100644 --- a/kernel/idle.c +++ b/kernel/idle.c @@ -18,21 +18,6 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); -void z_pm_save_idle_exit(void) -{ -#ifdef CONFIG_PM - /* Some CPU low power states require notification at the ISR - * to allow any operations that needs to be done before kernel - * switches task or processes nested interrupts. - * This can be simply ignored if not required. - */ - pm_system_resume(); -#endif /* CONFIG_PM */ -#ifdef CONFIG_SYS_CLOCK_EXISTS - sys_clock_idle_exit(); -#endif /* CONFIG_SYS_CLOCK_EXISTS */ -} - void idle(void *unused1, void *unused2, void *unused3) { ARG_UNUSED(unused1); diff --git a/subsys/pm/pm.c b/subsys/pm/pm.c index bb586073fcb..7389f963db6 100644 --- a/subsys/pm/pm.c +++ b/subsys/pm/pm.c @@ -280,3 +280,16 @@ const struct pm_state_info *pm_state_next_get(uint8_t cpu) { return &z_cpus_pm_state[cpu]; } + +void z_pm_save_idle_exit(void) +{ + /* Some CPU low power states require notification at the ISR + * to allow any operations that needs to be done before kernel + * switches task or processes nested interrupts. + * This can be simply ignored if not required. + */ + pm_system_resume(); +#ifdef CONFIG_SYS_CLOCK_EXISTS + sys_clock_idle_exit(); +#endif /* CONFIG_SYS_CLOCK_EXISTS */ +}