nanokernel: Add callback to _nano_timeout once again
It is now safe to introduce the callback since nano_timer_init now calls _nano_timeout_init which does takes care of initializing all the fields properly. Change-Id: I5735eeebef233a0a541ec8b2a354b65da98082fc Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
4afb4e4150
commit
967f8fb602
|
@ -59,11 +59,16 @@ struct _nano_queue {
|
||||||
|
|
||||||
#include <misc/dlist.h>
|
#include <misc/dlist.h>
|
||||||
|
|
||||||
|
struct _nano_timeout;
|
||||||
|
|
||||||
|
typedef void (*_nano_timeout_func_t)(struct _nano_timeout *t);
|
||||||
|
|
||||||
struct _nano_timeout {
|
struct _nano_timeout {
|
||||||
sys_dlist_t node;
|
sys_dlist_t node;
|
||||||
struct tcs *tcs;
|
struct tcs *tcs;
|
||||||
struct _nano_queue *wait_q;
|
struct _nano_queue *wait_q;
|
||||||
int32_t delta_ticks_from_prev;
|
int32_t delta_ticks_from_prev;
|
||||||
|
_nano_timeout_func_t func;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @endcond
|
* @endcond
|
||||||
|
|
|
@ -35,7 +35,8 @@ static inline void _do_nano_timeout_add(struct tcs *tcs,
|
||||||
struct _nano_queue *wait_q,
|
struct _nano_queue *wait_q,
|
||||||
int32_t timeout);
|
int32_t timeout);
|
||||||
|
|
||||||
static inline void _nano_timeout_init(struct _nano_timeout *t)
|
static inline void _nano_timeout_init(struct _nano_timeout *t,
|
||||||
|
_nano_timeout_func_t func)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Must be initialized here and when dequeueing a timeout so that code
|
* Must be initialized here and when dequeueing a timeout so that code
|
||||||
|
@ -55,6 +56,11 @@ static inline void _nano_timeout_init(struct _nano_timeout *t)
|
||||||
* routine can check if there is a fiber waiting on this timeout
|
* routine can check if there is a fiber waiting on this timeout
|
||||||
*/
|
*/
|
||||||
t->tcs = NULL;
|
t->tcs = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set callback function
|
||||||
|
*/
|
||||||
|
t->func = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_NANO_TIMEOUTS)
|
#if defined(CONFIG_NANO_TIMEOUTS)
|
||||||
|
@ -63,7 +69,7 @@ static inline void _nano_timeout_init(struct _nano_timeout *t)
|
||||||
|
|
||||||
static inline void _nano_timeout_tcs_init(struct tcs *tcs)
|
static inline void _nano_timeout_tcs_init(struct tcs *tcs)
|
||||||
{
|
{
|
||||||
_nano_timeout_init(&tcs->nano_timeout);
|
_nano_timeout_init(&tcs->nano_timeout, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are initialized when enqueing on the timeout queue:
|
* These are initialized when enqueing on the timeout queue:
|
||||||
|
@ -131,6 +137,8 @@ static inline struct _nano_timeout *_nano_timeout_handle_one_timeout(
|
||||||
} else {
|
} else {
|
||||||
_nano_fiber_ready(tcs);
|
_nano_fiber_ready(tcs);
|
||||||
}
|
}
|
||||||
|
} else if (t->func) {
|
||||||
|
t->func(t);
|
||||||
}
|
}
|
||||||
t->delta_ticks_from_prev = -1;
|
t->delta_ticks_from_prev = -1;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
void nano_timer_init(struct nano_timer *timer, void *data)
|
void nano_timer_init(struct nano_timer *timer, void *data)
|
||||||
{
|
{
|
||||||
/* initialize timeout_data */
|
/* initialize timeout_data */
|
||||||
_nano_timeout_init(&timer->timeout_data);
|
_nano_timeout_init(&timer->timeout_data, NULL);
|
||||||
|
|
||||||
/* nano_timer_test() returns NULL on timer that was not started */
|
/* nano_timer_test() returns NULL on timer that was not started */
|
||||||
timer->user_data = NULL;
|
timer->user_data = NULL;
|
||||||
|
|
Loading…
Reference in a new issue