kernel: Fix bug in dynamic alert initialization

k_alert_init() needs to set the "flags" field of its associated
work item to zero, indicating that the work item has not yet
been submitted to the system workqueue. Using the standard work
item initializer macro ensures this is done correctly.

Change-Id: I0001a5920f20fb1d8dc182191e6a549c5bf89be5
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
This commit is contained in:
Allan Stephens 2016-11-09 13:45:02 -06:00 committed by Anas Nashif
commit 3cd702010f

View file

@ -74,13 +74,9 @@ void _alert_deliver(struct k_work *work)
void k_alert_init(struct k_alert *alert, k_alert_handler_t handler, void k_alert_init(struct k_alert *alert, k_alert_handler_t handler,
unsigned int max_num_pending_alerts) unsigned int max_num_pending_alerts)
{ {
const struct k_work my_work_item = {
NULL, _alert_deliver, { max_num_pending_alerts }
};
alert->handler = handler; alert->handler = handler;
alert->send_count = ATOMIC_INIT(0); alert->send_count = ATOMIC_INIT(0);
alert->work_item = my_work_item; alert->work_item = (struct k_work)K_WORK_INITIALIZER(_alert_deliver);
k_sem_init(&alert->sem, 0, max_num_pending_alerts); k_sem_init(&alert->sem, 0, max_num_pending_alerts);
SYS_TRACING_OBJ_INIT(k_alert, alert); SYS_TRACING_OBJ_INIT(k_alert, alert);
} }