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:
parent
ee1e99b3b7
commit
4ab9d32bd3
1 changed files with 13 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue