Skip to content

Commit

Permalink
Merge pull request #20523 from MrKevinWeiss/pr/guard_shell_pm
Browse files Browse the repository at this point in the history
core|sys: Guard periph_pm calls
  • Loading branch information
maribu authored Apr 9, 2024
2 parents f5e6677 + b8c4617 commit 93b05d5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/lib/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void *main_trampoline(void *arg)
}
#endif

if (IS_ACTIVE(CONFIG_CORE_EXIT_WITH_MAIN)) {
if (IS_ACTIVE(CONFIG_CORE_EXIT_WITH_MAIN) && IS_USED(MODULE_PERIPH_PM)) {
pm_off();
}

Expand Down
2 changes: 2 additions & 0 deletions sys/newlib_syscalls_default/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ __attribute__((used)) void _fini(void)
__attribute__((used)) void _exit(int n)
{
LOG_INFO("#! exit %i: powering off\n", n);
#ifdef MODULE_PERIPH_PM
pm_off();
#endif
while (1) {}
}

Expand Down
2 changes: 2 additions & 0 deletions sys/picolibc_syscalls_default/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ void __attribute__((__noreturn__))
_exit(int n)
{
LOG_INFO("#! exit %i: powering off\n", n);
#ifdef MODULE_PERIPH_PM
pm_off();
#endif /* MODULE_PERIPH_PM */
for (;;) {
}
}
Expand Down
2 changes: 2 additions & 0 deletions sys/shell/cmds/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "riotboot/slot.h"
#endif

#ifdef MODULE_PERIPH_PM
static int _reboot_handler(int argc, char **argv)
{
(void) argc;
Expand All @@ -41,6 +42,7 @@ static int _reboot_handler(int argc, char **argv)
}

SHELL_COMMAND(reboot, "Reboot the node", _reboot_handler);
#endif /* MODULE_PERIPH_PM */

#ifdef MODULE_USB_BOARD_RESET
static int _bootloader_handler(int argc, char **argv)
Expand Down

0 comments on commit 93b05d5

Please sign in to comment.