Skip to content

Commit

Permalink
sched/wdog: Revert wd_cancel semantics
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Fix-Point committed Oct 9, 2024
1 parent 90836e5 commit 3f07717
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions sched/wdog/wd_cancel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
bool head = list_is_head(&g_wdactivelist, &wdog->node);

/* Now, remove the watchdog from the timer queue */
/* Now, remove the watchdog from the timer queue */

list_delete(&wdog->node);
list_delete(&wdog->node);

/* Mark the watchdog inactive */
/* Mark the watchdog inactive */

wdog->func = NULL;
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.
*/
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;
Expand Down

0 comments on commit 3f07717

Please sign in to comment.