sched/wdog: Use list_in_list() to detect active watchdogs

Use list_in_list() to determine whether a watchdog is active,
     eliminating the need to set the watchdog function pointer to NULL
     as an indicator of inactivity.

Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
This commit is contained in:
wangchengdong 2025-11-06 19:01:38 +08:00 committed by archer
parent 22a9228479
commit 190daef2bf
3 changed files with 1 additions and 7 deletions

View file

@ -39,7 +39,7 @@
* Pre-processor Definitions
****************************************************************************/
#define WDOG_ISACTIVE(w) ((w)->func != NULL)
#define WDOG_ISACTIVE(w) (list_in_list(&((w)->node)))
/* The maximum delay tick are supposed to be CLOCK_MAX >> 1.
* However, if there are expired wdog timers in the wdog queue,

View file

@ -86,9 +86,6 @@ int wd_cancel(FAR struct wdog_s *wdog)
list_delete(&wdog->node);
/* Mark the watchdog inactive */
wdog->func = NULL;
spin_unlock_irqrestore(&g_wdspinlock, flags);
if (head)

View file

@ -162,7 +162,6 @@ static inline_function void wd_expiration(clock_t ticks)
func = wdog->func;
arg = wdog->arg;
wdog->func = NULL;
/* Execute the watchdog function */
@ -310,7 +309,6 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks,
{
reassess |= list_is_head(&g_wdactivelist, &wdog->node);
list_delete(&wdog->node);
wdog->func = NULL;
}
reassess |= wd_insert(wdog, ticks, wdentry, arg);
@ -337,7 +335,6 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks,
if (WDOG_ISACTIVE(wdog))
{
list_delete(&wdog->node);
wdog->func = NULL;
}
wd_insert(wdog, ticks, wdentry, arg);