Skip to content

Commit 2a3b28a

Browse files
LingaoMfabiobaltieri
authored andcommitted
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 <[email protected]>
1 parent 8e88195 commit 2a3b28a

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

kernel/work.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,9 @@ static void queue_flusher_locked(struct k_work_q *queue,
188188
struct k_work *work,
189189
struct z_work_flusher *flusher)
190190
{
191-
bool in_list = false;
192-
struct k_work *wn;
193-
194-
/* Determine whether the work item is still queued. */
195-
SYS_SLIST_FOR_EACH_CONTAINER(&queue->pending, wn, node) {
196-
if (wn == work) {
197-
in_list = true;
198-
break;
199-
}
200-
}
201-
202191
init_flusher(flusher);
203-
if (in_list) {
192+
193+
if ((flags_get(&work->flags) & K_WORK_QUEUED) != 0U) {
204194
sys_slist_insert(&queue->pending, &work->node,
205195
&flusher->work.node);
206196
} else {

0 commit comments

Comments
 (0)