Skip to content

Commit 4af4450

Browse files
lyakhlgirdwood
authored andcommitted
schedule: dp: (cosmetic) simplify a loop
Convert a "while (1)" loop to a "do {} while (x)" loop to make the termination condition explicit and deduplicate a function call. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent f6bcb6f commit 4af4450

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/schedule/zephyr_dp_schedule.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,9 @@ static void dp_thread_fn(void *p1, void *p2, void *p3)
322322
struct task_dp_pdata *task_pdata = task->priv_data;
323323
unsigned int lock_key;
324324
enum task_state state;
325+
bool task_stop;
325326

326-
while (1) {
327+
do {
327328
/*
328329
* the thread is started immediately after creation, it will stop on semaphore
329330
* Semaphore will be released once the task is ready to process
@@ -360,14 +361,13 @@ static void dp_thread_fn(void *p1, void *p2, void *p3)
360361
}
361362
}
362363

363-
if (task->state == SOF_TASK_STATE_COMPLETED ||
364-
task->state == SOF_TASK_STATE_CANCEL)
365-
break; /* exit the while loop, terminate the thread */
364+
/* if true exit the while loop, terminate the thread */
365+
task_stop = task->state == SOF_TASK_STATE_COMPLETED ||
366+
task->state == SOF_TASK_STATE_CANCEL;
366367

367368
scheduler_dp_unlock(lock_key);
368-
}
369+
} while (!task_stop);
369370

370-
scheduler_dp_unlock(lock_key);
371371
/* call task_complete */
372372
if (task->state == SOF_TASK_STATE_COMPLETED)
373373
task_complete(task);

0 commit comments

Comments
 (0)