sched/wdog: Simplify the wd_timer_start.

This commit simplified the wd_timer_start.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen 2026-01-15 21:27:19 +08:00 committed by Donny(董九柱)
parent 4280e69a1c
commit 702e1d95f3
2 changed files with 18 additions and 15 deletions

View file

@ -111,6 +111,24 @@ int up_timer_gettick(FAR clock_t *ticks)
}
#endif
#if defined(CONFIG_SCHED_TICKLESS_ALARM) && !defined(CONFIG_ALARM_ARCH)
int up_alarm_tick_start(clock_t ticks)
{
struct timespec ts;
clock_ticks2time(&ts, ticks);
return up_alarm_start(&ts);
}
#endif
#if !defined(CONFIG_SCHED_TICKLESS_ALARM) && !defined(CONFIG_TIMER_ARCH)
int up_timer_tick_start(clock_t ticks)
{
struct timespec ts;
clock_ticks2time(&ts, ticks);
return up_timer_start(&ts);
}
#endif
static void nxsched_process_event(clock_t ticks, bool noswitches)
{
clock_t next;

View file

@ -115,24 +115,9 @@ static inline_function void wd_timer_start(clock_t tick)
{
clock_t next_tick = wd_adjust_next_tick(tick);
#ifdef CONFIG_SCHED_TICKLESS_ALARM
# ifndef CONFIG_ALARM_ARCH
struct timespec ts;
clock_ticks2time(&ts, next_tick);
up_alarm_start(&ts);
# else
up_alarm_tick_start(next_tick);
# endif
#else
# ifndef CONFIG_TIMER_ARCH
struct timespec ts1;
struct timespec ts2;
clock_ticks2time(&ts1, next_tick);
clock_systime_timespec(&ts2);
clock_timespec_subtract(&ts1, &ts2, &ts1);
up_timer_start(&ts1);
# else
up_timer_tick_start(next_tick - clock_systime_ticks());
# endif
#endif
}
static inline_function void wd_timer_cancel(void)