1
2#ifndef __LINUX_COMPLETION_H
3#define __LINUX_COMPLETION_H
4
5
6
7
8
9
10
11#ifndef __UBOOT__
12#include <linux/wait.h>
13#endif
14
15
16
17
18
19
20
21
22
23
24
25
26
27struct completion {
28 unsigned int done;
29#ifndef __UBOOT__
30 wait_queue_head_t wait;
31#endif
32};
33
34#define init_completion_map(x, m) __init_completion(x)
35#define init_completion(x) __init_completion(x)
36static inline void complete_acquire(struct completion *x) {}
37static inline void complete_release(struct completion *x) {}
38
39#define COMPLETION_INITIALIZER(work) \
40 { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
41
42#define COMPLETION_INITIALIZER_ONSTACK_MAP(work, map) \
43 (*({ init_completion_map(&(work), &(map)); &(work); }))
44
45#define COMPLETION_INITIALIZER_ONSTACK(work) \
46 (*({ init_completion(&work); &work; }))
47
48
49
50
51
52
53
54
55
56#define DECLARE_COMPLETION(work) \
57 struct completion work = COMPLETION_INITIALIZER(work)
58
59
60
61
62
63
64
65
66
67
68
69
70
71#ifdef CONFIG_LOCKDEP
72# define DECLARE_COMPLETION_ONSTACK(work) \
73 struct completion work = COMPLETION_INITIALIZER_ONSTACK(work)
74# define DECLARE_COMPLETION_ONSTACK_MAP(work, map) \
75 struct completion work = COMPLETION_INITIALIZER_ONSTACK_MAP(work, map)
76#else
77# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
78# define DECLARE_COMPLETION_ONSTACK_MAP(work, map) DECLARE_COMPLETION(work)
79#endif
80
81
82
83
84
85
86
87
88static inline void __init_completion(struct completion *x)
89{
90 x->done = 0;
91#ifndef __UBOOT__
92 init_waitqueue_head(&x->wait);
93#endif
94}
95
96
97
98
99
100
101
102
103static inline void reinit_completion(struct completion *x)
104{
105 x->done = 0;
106}
107
108#ifndef __UBOOT__
109extern void wait_for_completion(struct completion *);
110extern void wait_for_completion_io(struct completion *);
111extern int wait_for_completion_interruptible(struct completion *x);
112extern int wait_for_completion_killable(struct completion *x);
113extern unsigned long wait_for_completion_timeout(struct completion *x,
114 unsigned long timeout);
115extern unsigned long wait_for_completion_io_timeout(struct completion *x,
116 unsigned long timeout);
117extern long wait_for_completion_interruptible_timeout(
118 struct completion *x, unsigned long timeout);
119extern long wait_for_completion_killable_timeout(
120 struct completion *x, unsigned long timeout);
121extern bool try_wait_for_completion(struct completion *x);
122extern bool completion_done(struct completion *x);
123
124extern void complete(struct completion *);
125extern void complete_all(struct completion *);
126
127#else
128
129#define wait_for_completion(x) do {} while (0)
130#define wait_for_completion_io(x) do {} while (0)
131
132inline int wait_for_completion_interruptible(struct completion *x)
133{
134 return 1;
135}
136inline int wait_for_completion_killable(struct completion *x)
137{
138 return 1;
139}
140inline unsigned long wait_for_completion_timeout(struct completion *x,
141 unsigned long timeout)
142{
143 return 1;
144}
145inline unsigned long wait_for_completion_io_timeout(struct completion *x,
146 unsigned long timeout)
147{
148 return 1;
149}
150inline long wait_for_completion_interruptible_timeout(struct completion *x,
151 unsigned long timeout)
152{
153 return 1;
154}
155inline long wait_for_completion_killable_timeout(struct completion *x,
156 unsigned long timeout)
157{
158 return 1;
159}
160inline bool try_wait_for_completion(struct completion *x)
161{
162 return 1;
163}
164inline bool completion_done(struct completion *x)
165{
166 return 1;
167}
168
169#define complete(x) do {} while (0)
170#define complete_all(x) do {} while (0)
171#endif
172
173#endif
174