This is an automated email from the ASF dual-hosted git repository. ligd pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit a6d64a1a83de1b893a7eabb39be2f4550811b325 Author: ouyangxiangzhen <[email protected]> AuthorDate: Thu Jan 15 11:13:38 2026 +0800 sched/hrtimer: Simplify the hrtimer_cancel. This commit simplified the hrtimer_cancel. Signed-off-by: ouyangxiangzhen <[email protected]> --- sched/hrtimer/hrtimer_cancel.c | 14 +++++++------- sched/hrtimer/hrtimer_process.c | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/sched/hrtimer/hrtimer_cancel.c b/sched/hrtimer/hrtimer_cancel.c index bed9011a7f1..d77330c186d 100644 --- a/sched/hrtimer/hrtimer_cancel.c +++ b/sched/hrtimer/hrtimer_cancel.c @@ -94,16 +94,16 @@ int hrtimer_cancel(FAR hrtimer_t *hrtimer) if (hrtimer_is_armed(hrtimer)) { hrtimer_remove(hrtimer); - } - /* If the canceled timer was the earliest one, update the hardware timer */ + /* Update the hardware timer if the queue head changed. */ - if (hrtimer_is_first(hrtimer)) - { - first = hrtimer_get_first(); - if (first != NULL) + if (hrtimer_is_first(hrtimer)) { - hrtimer_reprogram(first->expired); + first = hrtimer_get_first(); + if (first != NULL) + { + hrtimer_reprogram(first->expired); + } } } diff --git a/sched/hrtimer/hrtimer_process.c b/sched/hrtimer/hrtimer_process.c index 9111d3991e8..d29a1240614 100644 --- a/sched/hrtimer/hrtimer_process.c +++ b/sched/hrtimer/hrtimer_process.c @@ -120,8 +120,6 @@ void hrtimer_process(uint64_t now) flags = write_seqlock_irqsave(&g_hrtimer_lock); - hrtimer_mark_running(NULL, cpu); - /* If the timer is periodic and has not been rearmed or * cancelled concurrently, * compute next expiration and reinsert into container @@ -129,7 +127,7 @@ void hrtimer_process(uint64_t now) if (period != 0u && hrtimer_is_running(hrtimer, cpu)) { - hrtimer->expired += period; + hrtimer->expired = expired + period; /* Ensure no overflow occurs */
