Lines Matching refs:work
570 static void triggered_work_handler(struct k_work *work) in triggered_work_handler() argument
573 CONTAINER_OF(work, struct k_work_poll, work); in triggered_work_handler()
590 twork->real_handler(work); in triggered_work_handler()
600 k_work_submit_to_queue(twork->workq, &twork->work); in triggered_work_expiration_handler()
604 struct k_work *work);
617 z_work_submit_to_queue(work_q, &twork->work); in signal_triggered_work()
623 static int triggered_work_cancel(struct k_work_poll *work, in triggered_work_cancel() argument
627 if (work->poller.is_polling && work->poller.mode != MODE_NONE) { in triggered_work_cancel()
629 z_abort_timeout(&work->timeout); in triggered_work_cancel()
635 work->poller.mode = MODE_NONE; in triggered_work_cancel()
638 clear_event_registrations(work->events, work->num_events, key); in triggered_work_cancel()
639 work->workq = NULL; in triggered_work_cancel()
653 void k_work_poll_init(struct k_work_poll *work, in k_work_poll_init() argument
656 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_work_poll, init, work); in k_work_poll_init()
658 *work = (struct k_work_poll) {}; in k_work_poll_init()
659 k_work_init(&work->work, triggered_work_handler); in k_work_poll_init()
660 work->real_handler = handler; in k_work_poll_init()
661 z_init_timeout(&work->timeout); in k_work_poll_init()
663 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_work_poll, init, work); in k_work_poll_init()
667 struct k_work_poll *work, in k_work_poll_submit_to_queue() argument
676 __ASSERT(work != NULL, "NULL work\n"); in k_work_poll_submit_to_queue()
680 SYS_PORT_TRACING_FUNC_ENTER(k_work_poll, submit_to_queue, work_q, work, timeout); in k_work_poll_submit_to_queue()
684 if (work->workq != NULL) { in k_work_poll_submit_to_queue()
685 if (work->workq == work_q) { in k_work_poll_submit_to_queue()
688 retval = triggered_work_cancel(work, key); in k_work_poll_submit_to_queue()
693 work, timeout, retval); in k_work_poll_submit_to_queue()
701 work, timeout, -EADDRINUSE); in k_work_poll_submit_to_queue()
708 work->poller.is_polling = true; in k_work_poll_submit_to_queue()
709 work->workq = work_q; in k_work_poll_submit_to_queue()
710 work->poller.mode = MODE_NONE; in k_work_poll_submit_to_queue()
714 work->events = events; in k_work_poll_submit_to_queue()
715 work->num_events = num_events; in k_work_poll_submit_to_queue()
718 work->poll_result = -EINPROGRESS; in k_work_poll_submit_to_queue()
722 &work->poller, false); in k_work_poll_submit_to_queue()
725 if (work->poller.is_polling && !K_TIMEOUT_EQ(timeout, K_NO_WAIT)) { in k_work_poll_submit_to_queue()
735 z_add_timeout(&work->timeout, in k_work_poll_submit_to_queue()
741 work->poller.mode = MODE_TRIGGERED; in k_work_poll_submit_to_queue()
744 SYS_PORT_TRACING_FUNC_EXIT(k_work_poll, submit_to_queue, work_q, work, timeout, 0); in k_work_poll_submit_to_queue()
760 if (work->poller.is_polling) { in k_work_poll_submit_to_queue()
761 work->poller.is_polling = false; in k_work_poll_submit_to_queue()
762 work->poll_result = -EAGAIN; in k_work_poll_submit_to_queue()
764 work->poll_result = 0; in k_work_poll_submit_to_queue()
772 k_work_submit_to_queue(work_q, &work->work); in k_work_poll_submit_to_queue()
774 SYS_PORT_TRACING_FUNC_EXIT(k_work_poll, submit_to_queue, work_q, work, timeout, 0); in k_work_poll_submit_to_queue()
779 int k_work_poll_submit(struct k_work_poll *work, in k_work_poll_submit() argument
784 SYS_PORT_TRACING_FUNC_ENTER(k_work_poll, submit, work, timeout); in k_work_poll_submit()
786 int ret = k_work_poll_submit_to_queue(&k_sys_work_q, work, in k_work_poll_submit()
789 SYS_PORT_TRACING_FUNC_EXIT(k_work_poll, submit, work, timeout, ret); in k_work_poll_submit()
794 int k_work_poll_cancel(struct k_work_poll *work) in k_work_poll_cancel() argument
799 SYS_PORT_TRACING_FUNC_ENTER(k_work_poll, cancel, work); in k_work_poll_cancel()
802 if (work == NULL || work->workq == NULL) { in k_work_poll_cancel()
803 SYS_PORT_TRACING_FUNC_EXIT(k_work_poll, cancel, work, -EINVAL); in k_work_poll_cancel()
809 retval = triggered_work_cancel(work, key); in k_work_poll_cancel()
812 SYS_PORT_TRACING_FUNC_EXIT(k_work_poll, cancel, work, retval); in k_work_poll_cancel()