source: GPL/trunk/include/linux/workqueue.h

Last change on this file was 772, checked in by David Azarewicz, 4 months ago

Merge in changes from 6.6-LTS branch.
Fixed additional 25+ problems.

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1#ifndef __LINUX_WORKQUEUE_H
2#define __LINUX_WORKQUEUE_H
3
4#include <linux/timer.h>
5#include <linux/completion.h>
6#include <linux/bitops.h>
7
8
9#define cancel_work_sync(w) flush_scheduled_work()
10/* we know this is used below exactly once for at most one waiter */
11
12struct work_struct {
13 unsigned long pending;
14 struct list_head entry;
15 void (*func)(void *);
16 void *data;
17 void *wq_data;
18 struct timer_list timer;
19};
20
21#define WORK_DATA_STATIC_INIT() \
22 ATOMIC_LONG_INIT((unsigned long)(WORK_STRUCT_NO_POOL | WORK_STRUCT_STATIC))
23
24struct workqueue_struct {
25 spinlock_t lock;
26 const char *name;
27 struct list_head worklist;
28 int task_pid;
29 struct task_struct *task;
30 wait_queue_head_t more_work;
31 wait_queue_head_t work_done;
32 struct completion thread_exited;
33};
34
35struct delayed_work {
36 struct work_struct work;
37 struct timer_list timer;
38
39 /* target workqueue and CPU ->timer uses to queue ->work */
40 struct workqueue_struct *wq;
41 int cpu;
42};
43
44struct workqueue_struct *create_workqueue(const char *name);
45void destroy_workqueue(struct workqueue_struct *wq);
46int queue_work(struct workqueue_struct *wq, struct work_struct *work);
47void flush_workqueue(struct workqueue_struct *wq);
48int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay);
49int cancel_delayed_work(struct delayed_work *dwork);
50
51#define INIT_WORK(_work, _func, _data) \
52 do { \
53 (_work)->func = _func; \
54 (_work)->data = _data; \
55 init_timer(&(_work)->timer); \
56 } while (0)
57#define __WORK_INITIALIZER(n, f) { \
58 .data = 0, \
59 .func = (void(*)(void *))(f), \
60 }
61
62#define DECLARE_WORK(n, f) \
63 struct work_struct n = __WORK_INITIALIZER(n, f)
64
65/* redefine INIT_WORK() */
66static inline void snd_INIT_WORK(struct work_struct *w, void (*f)(struct work_struct *))
67{
68 INIT_WORK(w, (void(*)(void*))(f), w);
69}
70#undef INIT_WORK
71#define INIT_WORK(w,f) snd_INIT_WORK(w,f)
72#define INIT_DELAYED_WORK(_work, _func) INIT_WORK(&(_work)->work, _func)
73#define work_pending(work) test_bit(0, &(work)->pending)
74#define delayed_work_pending(w) work_pending(&(w)->work)
75#define schedule_delayed_work(work, delay) queue_delayed_work(NULL, (work), (delay))
76
77#define create_singlethread_workqueue(name) create_workqueue(name)
78#define cancel_delayed_work_sync flush_delayed_work_sync
79
80/**
81 * schedule_work - put work task in global workqueue
82 * @work: job to be done
83 *
84 * Returns %false if @work was already on the kernel-global workqueue and
85 * %true otherwise.
86 *
87 * This puts a job in the kernel-global workqueue if it was not already
88 * queued and leaves it in the same position on the kernel-global
89 * workqueue otherwise.
90 */
91int schedule_work(struct work_struct *works);
92
93bool flush_delayed_work_sync(struct delayed_work *dwork);
94extern struct workqueue_struct *system_wq;
95
96/* I can't find a more suitable replacement... */
97#define flush_work(work) cancel_work_sync(work)
98
99#define container_of(ptr, type, member) \
100( (type *)( (char *)ptr - offsetof(type,member) ) )
101
102static inline struct delayed_work *to_delayed_work(struct work_struct *work)
103{
104 return container_of(work, struct delayed_work, work);
105}
106
107#endif /* __LINUX_WORKQUEUE_H */
Note: See TracBrowser for help on using the repository browser.