Skip to content

Commit b1b9e07

Browse files
HesselMrlubos
authored andcommitted
[nrf fromlist] arch: arm: cortex_m: pm_s2ram: fix system_off rv as rv of s2ram_suspend
The return value of the system_off call is overwritten by the the call to pm_s2ram_mark_check_and_clear. As arch_pm_s2ram_suspend needs to specify why system_off failed, we need to make sure the rv of system_off is moved to a safe register before calling pm_s2ram_mark_check_and_clear and moved to r0 als rv of arch_pm_s2ram_suspend when the suspend call exits. Upstream PR #: 80642 Signed-off-by: Hessel van der Molen <[email protected]> (cherry picked from commit a93ae9d)
1 parent f786239 commit b1b9e07

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/arm/core/cortex_m/pm_s2ram.S

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,19 @@ SECTION_FUNC(TEXT, arch_pm_s2ram_suspend)
8585
* not successful (in r0 the return value).
8686
*/
8787

88+
/* Move return value of system_off to callee-saved register. */
89+
mov r4, r0
90+
8891
/*
8992
* Reset the marking of suspend to RAM, return is ignored.
9093
*/
9194
mov r1, lr
9295
bl pm_s2ram_mark_check_and_clear
9396
mov lr, r1
9497

95-
/* Move system_off back to r0 as return value */
98+
/* Move the stored return value of system_off back to r0,
99+
* setting it as return value for this function.
100+
*/
96101
mov r0, r4
97102

98103
pop {r4-r12, lr}

0 commit comments

Comments
 (0)