blob: 3b3e2c8d037b762ff5aa294e0cdb7d6ee540e7de [file] [log] [blame]
Oleg Nesterove73f8952012-05-11 10:59:07 +10001#ifndef _LINUX_TASK_WORK_H
2#define _LINUX_TASK_WORK_H
3
4#include <linux/list.h>
5#include <linux/sched.h>
6
7struct task_work;
8typedef void (*task_work_func_t)(struct task_work *);
9
10struct task_work {
Al Viro158e1642012-06-27 09:24:13 +040011 struct task_work *next;
Oleg Nesterove73f8952012-05-11 10:59:07 +100012 task_work_func_t func;
Oleg Nesterove73f8952012-05-11 10:59:07 +100013};
14
15static inline void
Al Viro41f9d292012-06-26 22:10:04 +040016init_task_work(struct task_work *twork, task_work_func_t func)
Oleg Nesterove73f8952012-05-11 10:59:07 +100017{
18 twork->func = func;
Oleg Nesterove73f8952012-05-11 10:59:07 +100019}
20
21int task_work_add(struct task_struct *task, struct task_work *twork, bool);
22struct task_work *task_work_cancel(struct task_struct *, task_work_func_t);
23void task_work_run(void);
24
25static inline void exit_task_work(struct task_struct *task)
26{
Al Viro158e1642012-06-27 09:24:13 +040027 if (unlikely(task->task_works))
Oleg Nesterove73f8952012-05-11 10:59:07 +100028 task_work_run();
29}
30
31#endif /* _LINUX_TASK_WORK_H */