kernel: work: remove unused if statement
Condition of work == NULL is checked before, so there is no need to check it again. Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
This commit is contained in:
parent
82b290ef48
commit
d4826d874e
1 changed files with 21 additions and 24 deletions
|
@ -586,6 +586,7 @@ static void work_queue_main(void *workq_ptr, void *p2, void *p3)
|
||||||
struct k_work *work = NULL;
|
struct k_work *work = NULL;
|
||||||
k_work_handler_t handler = NULL;
|
k_work_handler_t handler = NULL;
|
||||||
k_spinlock_key_t key = k_spin_lock(&lock);
|
k_spinlock_key_t key = k_spin_lock(&lock);
|
||||||
|
bool yield;
|
||||||
|
|
||||||
/* Check for and prepare any new work. */
|
/* Check for and prepare any new work. */
|
||||||
node = sys_slist_get(&queue->pending);
|
node = sys_slist_get(&queue->pending);
|
||||||
|
@ -644,34 +645,30 @@ static void work_queue_main(void *workq_ptr, void *p2, void *p3)
|
||||||
|
|
||||||
k_spin_unlock(&lock, key);
|
k_spin_unlock(&lock, key);
|
||||||
|
|
||||||
if (work != NULL) {
|
__ASSERT_NO_MSG(handler != NULL);
|
||||||
bool yield;
|
handler(work);
|
||||||
|
|
||||||
__ASSERT_NO_MSG(handler != NULL);
|
/* Mark the work item as no longer running and deal
|
||||||
handler(work);
|
* with any cancellation issued while it was running.
|
||||||
|
* Clear the BUSY flag and optionally yield to prevent
|
||||||
|
* starving other threads.
|
||||||
|
*/
|
||||||
|
key = k_spin_lock(&lock);
|
||||||
|
|
||||||
/* Mark the work item as no longer running and deal
|
flag_clear(&work->flags, K_WORK_RUNNING_BIT);
|
||||||
* with any cancellation issued while it was running.
|
if (flag_test(&work->flags, K_WORK_CANCELING_BIT)) {
|
||||||
* Clear the BUSY flag and optionally yield to prevent
|
finalize_cancel_locked(work);
|
||||||
* starving other threads.
|
}
|
||||||
*/
|
|
||||||
key = k_spin_lock(&lock);
|
|
||||||
|
|
||||||
flag_clear(&work->flags, K_WORK_RUNNING_BIT);
|
flag_clear(&queue->flags, K_WORK_QUEUE_BUSY_BIT);
|
||||||
if (flag_test(&work->flags, K_WORK_CANCELING_BIT)) {
|
yield = !flag_test(&queue->flags, K_WORK_QUEUE_NO_YIELD_BIT);
|
||||||
finalize_cancel_locked(work);
|
k_spin_unlock(&lock, key);
|
||||||
}
|
|
||||||
|
|
||||||
flag_clear(&queue->flags, K_WORK_QUEUE_BUSY_BIT);
|
/* Optionally yield to prevent the work queue from
|
||||||
yield = !flag_test(&queue->flags, K_WORK_QUEUE_NO_YIELD_BIT);
|
* starving other threads.
|
||||||
k_spin_unlock(&lock, key);
|
*/
|
||||||
|
if (yield) {
|
||||||
/* Optionally yield to prevent the work queue from
|
k_yield();
|
||||||
* starving other threads.
|
|
||||||
*/
|
|
||||||
if (yield) {
|
|
||||||
k_yield();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue