mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #17408 from chrysn-pull-requests/ztimer-report-removal
sys/ztimer: ztimer_remove report success
This commit is contained in:
commit
9e35b75ff4
@ -365,6 +365,9 @@ struct ztimer_clock {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief main ztimer callback handler
|
* @brief main ztimer callback handler
|
||||||
|
*
|
||||||
|
* This gets called by clock implementations, and must only be called by them
|
||||||
|
* with interrupts disabled.
|
||||||
*/
|
*/
|
||||||
void ztimer_handler(ztimer_clock_t *clock);
|
void ztimer_handler(ztimer_clock_t *clock);
|
||||||
|
|
||||||
@ -408,8 +411,14 @@ unsigned ztimer_is_set(const ztimer_clock_t *clock, const ztimer_t *timer);
|
|||||||
*
|
*
|
||||||
* @param[in] clock ztimer clock to operate on
|
* @param[in] clock ztimer clock to operate on
|
||||||
* @param[in] timer timer entry to remove
|
* @param[in] timer timer entry to remove
|
||||||
|
*
|
||||||
|
* @retval true The timer was removed (and thus its callback neither was nor
|
||||||
|
* will be called by ztimer).
|
||||||
|
* @retval false The timer fired previously or is not set on the @p clock
|
||||||
|
* at all.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
void ztimer_remove(ztimer_clock_t *clock, ztimer_t *timer);
|
bool ztimer_remove(ztimer_clock_t *clock, ztimer_t *timer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Post a message after a delay
|
* @brief Post a message after a delay
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
static void _add_entry_to_list(ztimer_clock_t *clock, ztimer_base_t *entry);
|
static void _add_entry_to_list(ztimer_clock_t *clock, ztimer_base_t *entry);
|
||||||
static void _del_entry_from_list(ztimer_clock_t *clock, ztimer_base_t *entry);
|
static bool _del_entry_from_list(ztimer_clock_t *clock, ztimer_base_t *entry);
|
||||||
static void _ztimer_update(ztimer_clock_t *clock);
|
static void _ztimer_update(ztimer_clock_t *clock);
|
||||||
static void _ztimer_print(const ztimer_clock_t *clock);
|
static void _ztimer_print(const ztimer_clock_t *clock);
|
||||||
static uint32_t _ztimer_update_head_offset(ztimer_clock_t *clock);
|
static uint32_t _ztimer_update_head_offset(ztimer_clock_t *clock);
|
||||||
@ -68,18 +68,20 @@ unsigned ztimer_is_set(const ztimer_clock_t *clock, const ztimer_t *timer)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ztimer_remove(ztimer_clock_t *clock, ztimer_t *timer)
|
bool ztimer_remove(ztimer_clock_t *clock, ztimer_t *timer)
|
||||||
{
|
{
|
||||||
|
bool was_removed = false;
|
||||||
unsigned state = irq_disable();
|
unsigned state = irq_disable();
|
||||||
|
|
||||||
if (_is_set(clock, timer)) {
|
if (_is_set(clock, timer)) {
|
||||||
_ztimer_update_head_offset(clock);
|
_ztimer_update_head_offset(clock);
|
||||||
_del_entry_from_list(clock, &timer->base);
|
was_removed = _del_entry_from_list(clock, &timer->base);
|
||||||
|
|
||||||
_ztimer_update(clock);
|
_ztimer_update(clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
irq_restore(state);
|
irq_restore(state);
|
||||||
|
return was_removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ztimer_set(ztimer_clock_t *clock, ztimer_t *timer, uint32_t val)
|
uint32_t ztimer_set(ztimer_clock_t *clock, ztimer_t *timer, uint32_t val)
|
||||||
@ -232,8 +234,10 @@ static uint32_t _ztimer_update_head_offset(ztimer_clock_t *clock)
|
|||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _del_entry_from_list(ztimer_clock_t *clock, ztimer_base_t *entry)
|
static bool _del_entry_from_list(ztimer_clock_t *clock, ztimer_base_t *entry)
|
||||||
{
|
{
|
||||||
|
bool was_removed = false;
|
||||||
|
|
||||||
DEBUG("_del_entry_from_list()\n");
|
DEBUG("_del_entry_from_list()\n");
|
||||||
ztimer_base_t *list = &clock->list;
|
ztimer_base_t *list = &clock->list;
|
||||||
|
|
||||||
@ -254,6 +258,7 @@ static void _del_entry_from_list(ztimer_clock_t *clock, ztimer_base_t *entry)
|
|||||||
list_entry->offset += entry->offset;
|
list_entry->offset += entry->offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
was_removed = true;
|
||||||
/* reset the entry's next pointer so _is_set() considers it unset */
|
/* reset the entry's next pointer so _is_set() considers it unset */
|
||||||
entry->next = NULL;
|
entry->next = NULL;
|
||||||
break;
|
break;
|
||||||
@ -268,6 +273,8 @@ static void _del_entry_from_list(ztimer_clock_t *clock, ztimer_base_t *entry)
|
|||||||
pm_unblock(clock->block_pm_mode);
|
pm_unblock(clock->block_pm_mode);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return was_removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ztimer_t *_now_next(ztimer_clock_t *clock)
|
static ztimer_t *_now_next(ztimer_clock_t *clock)
|
||||||
|
Loading…
Reference in New Issue
Block a user