Skip to content

Commit

Permalink
[nrf fromtree] kernel: timeout: ensure next timeout is set when abort…
Browse files Browse the repository at this point in the history
…ing the first timeout

Ref: NCSDK-31290

This ensures that the system clock is correctly updated when the first
timeout is aborted, preventing unexpected early wake-up by the system clock
programmed previously.

Signed-off-by: Dong Wang <[email protected]>
(cherry picked from commit dd5f11c)
  • Loading branch information
kwd-doodling authored and jonathannilsen committed Jan 15, 2025
1 parent 52a1cee commit 4a25772
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kernel/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,13 @@ int z_abort_timeout(struct _timeout *to)

K_SPINLOCK(&timeout_lock) {
if (sys_dnode_is_linked(&to->node)) {
bool is_first = (to == first());

remove_timeout(to);
ret = 0;
if (is_first) {
sys_clock_set_timeout(next_timeout(), false);
}
}
}

Expand Down

0 comments on commit 4a25772

Please sign in to comment.