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
+7 -7
View File
@@ -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);
}
}
}
+1 -3
View File
@@ -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 */