sched/wdog: Revert wd_cancel semantics

In the original implementation, if wdog is not ACTIVE, -EINVAL will be returned. The rp2040 i2c driver relies on this semantics to correctly release the semaphore.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen 2024-10-09 21:22:55 +08:00 committed by Alan C. Assis
parent e249dd2672
commit 110ab50f50
1 changed files with 17 additions and 20 deletions

View File

@ -91,7 +91,7 @@ int wd_cancel(FAR struct wdog_s *wdog)
int wd_cancel_irq(FAR struct wdog_s *wdog)
{
if (wdog == NULL)
if (wdog == NULL || !WDOG_ISACTIVE(wdog))
{
return -EINVAL;
}
@ -105,27 +105,24 @@ int wd_cancel_irq(FAR struct wdog_s *wdog)
/* Make sure that the watchdog is still active. */
if (WDOG_ISACTIVE(wdog))
bool head = list_is_head(&g_wdactivelist, &wdog->node);
/* Now, remove the watchdog from the timer queue */
list_delete(&wdog->node);
/* Mark the watchdog inactive */
wdog->func = NULL;
if (head)
{
bool head = list_is_head(&g_wdactivelist, &wdog->node);
/* If the watchdog is at the head of the timer queue, then
* we will need to re-adjust the interval timer that will
* generate the next interval event.
*/
/* Now, remove the watchdog from the timer queue */
list_delete(&wdog->node);
/* Mark the watchdog inactive */
wdog->func = NULL;
if (head)
{
/* If the watchdog is at the head of the timer queue, then
* we will need to re-adjust the interval timer that will
* generate the next interval event.
*/
nxsched_reassess_timer();
}
nxsched_reassess_timer();
}
return OK;