From fb6ab560a5ce809fcb6d1bcba290f77e7b561991 Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Wed, 17 Apr 2024 08:55:20 +0100 Subject: [PATCH] arch: arm: cortex_m: fix inverted logic in cpu_idle This mistake was introduced when converting from ASM to C. This change also restores the associated comment from the ASM source. Signed-off-by: Wilfried Chauveau --- arch/arm/core/cortex_m/cpu_idle.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/core/cortex_m/cpu_idle.c b/arch/arm/core/cortex_m/cpu_idle.c index 39f3c7de774..6506b34531e 100644 --- a/arch/arm/core/cortex_m/cpu_idle.c +++ b/arch/arm/core/cortex_m/cpu_idle.c @@ -35,9 +35,13 @@ void z_arm_cpu_idle_init(void) #if defined(CONFIG_ARM_ON_ENTER_CPU_IDLE_HOOK) #define SLEEP_IF_ALLOWED(wait_instr) do { \ - if (!z_arm_on_enter_cpu_idle()) { \ + /* Skip the wait instr if on_enter_cpu_idle returns false */ \ + if (z_arm_on_enter_cpu_idle()) { \ + /* Wait for all memory transaction to complete */ \ + /* before entering low power state. */ \ __DSB(); \ wait_instr(); \ + /* Inline the macro provided by SoC-specific code */ \ ON_EXIT_IDLE_HOOK; \ } \ } while (false)