Lines Matching refs:work

38  * Define all work struct states
66 * This function atomically updates the work state and returns the
91 linux_work_exec_unblock(struct work_struct *work)
97 wq = work->work_queue;
103 if (exec->target == work) {
119 tq = dwork->work.work_queue->taskqueue;
120 taskqueue_enqueue(tq, &dwork->work.work_task);
124 * This function queues the given work structure on the given
125 * workqueue. It returns non-zero if the work was successfully
126 * [re-]queued. Else the work is already pending for completion.
130 struct work_struct *work)
141 return (!work_pending(work));
143 switch (linux_update_state(&work->state, states)) {
146 if (linux_work_exec_unblock(work) != 0)
150 work->work_queue = wq;
151 taskqueue_enqueue(wq->taskqueue, &work->work_task);
159 * This function queues the given work structure on the given
161 * work was successfully [re-]queued. Else the work is already pending
177 return (!work_pending(&dwork->work));
179 switch (linux_update_state(&dwork->work.state, states)) {
182 if (delay == 0 && linux_work_exec_unblock(&dwork->work) != 0) {
188 dwork->work.work_queue = wq;
215 [WORK_ST_TIMER] = WORK_ST_EXEC, /* delayed work w/o timeout */
220 struct work_struct *work;
228 work = context;
229 wq = work->work_queue;
232 exec.target = work;
238 switch (linux_update_state(&work->state, states)) {
244 /* set current work structure */
245 task->work = work;
247 /* call work function */
248 work->func(work);
250 /* set current work structure */
251 task->work = NULL;
255 if (exec.target != work) {
257 exec.target = work;
277 * Make sure the timer belonging to the delayed work gets
278 * drained before invoking the work function. Else the timer
280 * situations, because the work function might free the work
285 linux_work_fn(&dwork->work, pending);
300 switch (linux_update_state(&dwork->work.state, states)) {
311 * This function cancels the given work structure in a synchronous
312 * fashion. It returns non-zero if the work was successfully
313 * cancelled. Else the work was already cancelled.
316 linux_cancel_work_sync(struct work_struct *work)
331 switch (linux_update_state(&work->state, states)) {
336 tq = work->work_queue->taskqueue;
337 if (taskqueue_cancel(tq, &work->work_task, NULL) != 0)
338 taskqueue_drain(tq, &work->work_task);
339 goto retry; /* work may have restarted itself */
341 tq = work->work_queue->taskqueue;
342 if (taskqueue_cancel(tq, &work->work_task, NULL) != 0)
343 taskqueue_drain(tq, &work->work_task);
371 * This function cancels the given delayed work structure in a
372 * non-blocking fashion. It returns non-zero if the work was
373 * successfully cancelled. Else the work may still be busy or already
388 switch (linux_update_state(&dwork->work.state, states)) {
392 atomic_cmpxchg(&dwork->work.state,
398 tq = dwork->work.work_queue->taskqueue;
399 if (taskqueue_cancel(tq, &dwork->work.work_task, NULL) == 0) {
400 atomic_cmpxchg(&dwork->work.state,
411 * This function cancels the given work structure in a synchronous
412 * fashion. It returns non-zero if the work was successfully
413 * cancelled. Else the work was already cancelled.
431 switch (linux_update_state(&dwork->work.state, states)) {
435 tq = dwork->work.work_queue->taskqueue;
436 if (taskqueue_cancel(tq, &dwork->work.work_task, NULL) != 0)
437 taskqueue_drain(tq, &dwork->work.work_task);
438 goto retry; /* work may have restarted itself */
446 tq = dwork->work.work_queue->taskqueue;
447 taskqueue_drain(tq, &dwork->work.work_task);
453 tq = dwork->work.work_queue->taskqueue;
454 if (taskqueue_cancel(tq, &dwork->work.work_task, NULL) != 0)
455 taskqueue_drain(tq, &dwork->work.work_task);
462 * This function waits until the given work structure is completed.
463 * It returns non-zero if the work was successfully
464 * waited for. Else the work was not waited for.
467 linux_flush_work(struct work_struct *work)
475 switch (atomic_read(&work->state)) {
479 tq = work->work_queue->taskqueue;
480 retval = taskqueue_poll_is_busy(tq, &work->work_task);
481 taskqueue_drain(tq, &work->work_task);
487 * This function waits until the given delayed work structure is
488 * completed. It returns non-zero if the work was successfully waited
489 * for. Else the work was not waited for.
500 switch (atomic_read(&dwork->work.state)) {
508 tq = dwork->work.work_queue->taskqueue;
509 retval = taskqueue_poll_is_busy(tq, &dwork->work.work_task);
510 taskqueue_drain(tq, &dwork->work.work_task);
516 * This function returns true if the given work is pending, and not
520 linux_work_pending(struct work_struct *work)
522 switch (atomic_read(&work->state)) {
533 * This function returns true if the given work is busy.
536 linux_work_busy(struct work_struct *work)
540 switch (atomic_read(&work->state)) {
544 tq = work->work_queue->taskqueue;
545 return (taskqueue_poll_is_busy(tq, &work->work_task));
587 dwork->work.func = func;
588 TASK_INIT(&dwork->work.work_task, 0, linux_delayed_work_fn, dwork);
597 return (current->work);