From 30188dc587a93a6c76854096e358973d68505d0b Mon Sep 17 00:00:00 2001 From: buxiasen Date: Fri, 31 May 2024 21:06:35 +0800 Subject: [PATCH] watchdog: fix idle callback maybe not upperhalf Signed-off-by: buxiasen --- drivers/timers/watchdog.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/timers/watchdog.c b/drivers/timers/watchdog.c index c055776b1c..e16e8d9244 100644 --- a/drivers/timers/watchdog.c +++ b/drivers/timers/watchdog.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include #include @@ -213,8 +214,11 @@ static void watchdog_automonitor_worker(FAR void *arg) static void watchdog_automonitor_idle(FAR struct pm_callback_s *cb, int domain, enum pm_state_e pmstate) { - FAR struct watchdog_upperhalf_s *upper = (FAR void *)cb; - FAR struct watchdog_lowerhalf_s *lower = upper->lower; + FAR struct watchdog_upperhalf_s *upper; + FAR struct watchdog_lowerhalf_s *lower; + + upper = container_of(cb, struct watchdog_upperhalf_s, idle); + lower = upper->lower; if (domain == PM_IDLE_DOMAIN && pmstate != PM_RESTORE && upper->monitor)