sched/hrtimer: Simplify the hrtimer_cancel.

This commit simplified the hrtimer_cancel.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen
2026-01-15 11:13:38 +08:00
committed by GUIDINGLI
parent 4d283260ab
commit a6d64a1a83
2 changed files with 8 additions and 10 deletions
+2 -2
View File
@@ -94,9 +94,8 @@ int hrtimer_cancel(FAR hrtimer_t *hrtimer)
if (hrtimer_is_armed(hrtimer)) if (hrtimer_is_armed(hrtimer))
{ {
hrtimer_remove(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)) if (hrtimer_is_first(hrtimer))
{ {
@@ -106,6 +105,7 @@ int hrtimer_cancel(FAR hrtimer_t *hrtimer)
hrtimer_reprogram(first->expired); hrtimer_reprogram(first->expired);
} }
} }
}
/* Leave critical section */ /* Leave critical section */
+1 -3
View File
@@ -120,8 +120,6 @@ void hrtimer_process(uint64_t now)
flags = write_seqlock_irqsave(&g_hrtimer_lock); flags = write_seqlock_irqsave(&g_hrtimer_lock);
hrtimer_mark_running(NULL, cpu);
/* If the timer is periodic and has not been rearmed or /* If the timer is periodic and has not been rearmed or
* cancelled concurrently, * cancelled concurrently,
* compute next expiration and reinsert into container * 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)) if (period != 0u && hrtimer_is_running(hrtimer, cpu))
{ {
hrtimer->expired += period; hrtimer->expired = expired + period;
/* Ensure no overflow occurs */ /* Ensure no overflow occurs */