work: Convert usage of k_fifo to k_queue
Make use of k_queue directly since it has a more flexible API. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
84db641de6
commit
adb581be8e
2 changed files with 6 additions and 6 deletions
|
@ -1957,7 +1957,7 @@ typedef void (*k_work_handler_t)(struct k_work *work);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct k_work_q {
|
struct k_work_q {
|
||||||
struct k_fifo fifo;
|
struct k_queue queue;
|
||||||
struct k_thread thread;
|
struct k_thread thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1966,7 +1966,7 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct k_work {
|
struct k_work {
|
||||||
void *_reserved; /* Used by k_fifo implementation. */
|
void *_reserved; /* Used by k_queue implementation. */
|
||||||
k_work_handler_t handler;
|
k_work_handler_t handler;
|
||||||
atomic_t flags[1];
|
atomic_t flags[1];
|
||||||
};
|
};
|
||||||
|
@ -2049,7 +2049,7 @@ static inline void k_work_submit_to_queue(struct k_work_q *work_q,
|
||||||
struct k_work *work)
|
struct k_work *work)
|
||||||
{
|
{
|
||||||
if (!atomic_test_and_set_bit(work->flags, K_WORK_STATE_PENDING)) {
|
if (!atomic_test_and_set_bit(work->flags, K_WORK_STATE_PENDING)) {
|
||||||
k_fifo_put(&work_q->fifo, work);
|
k_fifo_put(&work_q->queue, work);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,13 @@ static void work_q_main(void *work_q_ptr, void *p2, void *p3)
|
||||||
struct k_work *work;
|
struct k_work *work;
|
||||||
k_work_handler_t handler;
|
k_work_handler_t handler;
|
||||||
|
|
||||||
work = k_fifo_get(&work_q->fifo, K_FOREVER);
|
work = k_queue_get(&work_q->queue, K_FOREVER);
|
||||||
|
|
||||||
handler = work->handler;
|
handler = work->handler;
|
||||||
|
|
||||||
/* Reset pending state so it can be resubmitted by handler */
|
/* Reset pending state so it can be resubmitted by handler */
|
||||||
if (atomic_test_and_clear_bit(work->flags,
|
if (atomic_test_and_clear_bit(work->flags,
|
||||||
K_WORK_STATE_PENDING)) {
|
K_WORK_STATE_PENDING)) {
|
||||||
handler(work);
|
handler(work);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ static void work_q_main(void *work_q_ptr, void *p2, void *p3)
|
||||||
void k_work_q_start(struct k_work_q *work_q, k_thread_stack_t stack,
|
void k_work_q_start(struct k_work_q *work_q, k_thread_stack_t stack,
|
||||||
size_t stack_size, int prio)
|
size_t stack_size, int prio)
|
||||||
{
|
{
|
||||||
k_fifo_init(&work_q->fifo);
|
k_queue_init(&work_q->queue);
|
||||||
|
|
||||||
k_thread_create(&work_q->thread, stack, stack_size, work_q_main,
|
k_thread_create(&work_q->thread, stack, stack_size, work_q_main,
|
||||||
work_q, 0, 0, prio, 0, 0);
|
work_q, 0, 0, prio, 0, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue