unified: Don't assert if work is pending on submit

This makes k_work_submit to allow resubmits when the work is pending so
the user code don't have to check the pending flag to avoid a possible
assert.

Change-Id: Ic39f3dc5936837ce84ad028cf3d426d0558c2925
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2016-09-26 09:39:27 +03:00
commit 4ab9d32bd3

View file

@ -512,13 +512,23 @@ static inline void k_work_init(struct k_work *work, k_work_handler_t handler)
/**
* @brief Submit a work item to a workqueue.
*
* This procedure schedules a work item to be processed.
* In the case where the work item has already been submitted and is pending
* execution, calling this function will result in a no-op. In this case, the
* work item must not be modified externally (e.g. by the caller of this
* function), since that could cause the work item to be processed in a
* corrupted state.
*
* @param work_q to schedule the work item
* @param work work item
*
* @return N/A
*/
static inline void k_work_submit_to_queue(struct k_work_q *work_q,
struct k_work *work)
{
if (atomic_test_and_set_bit(work->flags, K_WORK_STATE_PENDING)) {
__ASSERT_NO_MSG(0);
} else {
if (!atomic_test_and_set_bit(work->flags, K_WORK_STATE_PENDING)) {
k_fifo_put(&work_q->fifo, work);
}
}