kernel: timeout: ensure next timeout is set when aborting the first timeout

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 <dong.d.wang@intel.com>
This commit is contained in:
Dong Wang 2025-01-02 13:48:40 +08:00 committed by Benjamin Cabé
parent 6ba0563fe2
commit dd5f11cb04

View file

@ -147,8 +147,13 @@ int z_abort_timeout(struct _timeout *to)
K_SPINLOCK(&timeout_lock) { K_SPINLOCK(&timeout_lock) {
if (sys_dnode_is_linked(&to->node)) { if (sys_dnode_is_linked(&to->node)) {
bool is_first = (to == first());
remove_timeout(to); remove_timeout(to);
ret = 0; ret = 0;
if (is_first) {
sys_clock_set_timeout(next_timeout(), false);
}
} }
} }