From 2a3b28a3f50440438ce6a81fa5aae17763b68029 Mon Sep 17 00:00:00 2001 From: Lingao Meng Date: Tue, 24 Sep 2024 10:50:59 +0800 Subject: [PATCH] kernel: work: Remove meanless foreach for work Since call this function both in ```C k_spinlock_key_t key = k_spin_lock(&lock); bool need_flush = work_flush_locked(work, flusher); k_spin_unlock(&lock, key); ``` So, there are no flag_get change. Signed-off-by: Lingao Meng --- kernel/work.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/kernel/work.c b/kernel/work.c index 994d6d74e80..1163db9f0b8 100644 --- a/kernel/work.c +++ b/kernel/work.c @@ -188,19 +188,9 @@ static void queue_flusher_locked(struct k_work_q *queue, struct k_work *work, struct z_work_flusher *flusher) { - bool in_list = false; - struct k_work *wn; - - /* Determine whether the work item is still queued. */ - SYS_SLIST_FOR_EACH_CONTAINER(&queue->pending, wn, node) { - if (wn == work) { - in_list = true; - break; - } - } - init_flusher(flusher); - if (in_list) { + + if ((flags_get(&work->flags) & K_WORK_QUEUED) != 0U) { sys_slist_insert(&queue->pending, &work->node, &flusher->work.node); } else {