• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/include/linux/
1#ifndef _LINUX_WAIT_H
2#define _LINUX_WAIT_H
3
4#define WNOHANG		0x00000001
5#define WUNTRACED	0x00000002
6#define WSTOPPED	WUNTRACED
7#define WEXITED		0x00000004
8#define WCONTINUED	0x00000008
9#define WNOWAIT		0x01000000	/* Don't reap, just poll status.  */
10
11#define __WNOTHREAD	0x20000000	/* Don't wait on children of other threads in this group */
12#define __WALL		0x40000000	/* Wait on all children, regardless of type */
13#define __WCLONE	0x80000000	/* Wait only on non-SIGCHLD children */
14
15/* First argument to waitid: */
16#define P_ALL		0
17#define P_PID		1
18#define P_PGID		2
19
20#ifdef __KERNEL__
21
22#include <linux/list.h>
23#include <linux/stddef.h>
24#include <linux/spinlock.h>
25#include <asm/system.h>
26#include <asm/current.h>
27
28typedef struct __wait_queue wait_queue_t;
29typedef int (*wait_queue_func_t)(wait_queue_t *wait, unsigned mode, int flags, void *key);
30int default_wake_function(wait_queue_t *wait, unsigned mode, int flags, void *key);
31
32/* __wait_queue::flags */
33#define WQ_FLAG_EXCLUSIVE       0x01
34#define WQ_FLAG_WOKEN           0x02
35
36struct __wait_queue {
37	unsigned int flags;
38	void *private;
39	wait_queue_func_t func;
40	struct list_head task_list;
41};
42
43struct wait_bit_key {
44	void *flags;
45	int bit_nr;
46};
47
48struct wait_bit_queue {
49	struct wait_bit_key key;
50	wait_queue_t wait;
51};
52
53struct __wait_queue_head {
54	spinlock_t lock;
55	struct list_head task_list;
56};
57typedef struct __wait_queue_head wait_queue_head_t;
58
59struct task_struct;
60
61/*
62 * Macros for declaration and initialisaton of the datatypes
63 */
64
65#define __WAITQUEUE_INITIALIZER(name, tsk) {				\
66	.private	= tsk,						\
67	.func		= default_wake_function,			\
68	.task_list	= { NULL, NULL } }
69
70#define DECLARE_WAITQUEUE(name, tsk)					\
71	wait_queue_t name = __WAITQUEUE_INITIALIZER(name, tsk)
72
73#define __WAIT_QUEUE_HEAD_INITIALIZER(name) {				\
74	.lock		= __SPIN_LOCK_UNLOCKED(name.lock),		\
75	.task_list	= { &(name).task_list, &(name).task_list } }
76
77#define DECLARE_WAIT_QUEUE_HEAD(name) \
78	wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
79
80#define __WAIT_BIT_KEY_INITIALIZER(word, bit)				\
81	{ .flags = word, .bit_nr = bit, }
82
83extern void __init_waitqueue_head(wait_queue_head_t *q, struct lock_class_key *);
84
85#define init_waitqueue_head(q)				\
86	do {						\
87		static struct lock_class_key __key;	\
88							\
89		__init_waitqueue_head((q), &__key);	\
90	} while (0)
91
92#ifdef CONFIG_LOCKDEP
93# define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) \
94	({ init_waitqueue_head(&name); name; })
95# define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) \
96	wait_queue_head_t name = __WAIT_QUEUE_HEAD_INIT_ONSTACK(name)
97#else
98# define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) DECLARE_WAIT_QUEUE_HEAD(name)
99#endif
100
101static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p)
102{
103	q->flags = 0;
104	q->private = p;
105	q->func = default_wake_function;
106}
107
108static inline void init_waitqueue_func_entry(wait_queue_t *q,
109					wait_queue_func_t func)
110{
111	q->flags = 0;
112	q->private = NULL;
113	q->func = func;
114}
115
116static inline int waitqueue_active(wait_queue_head_t *q)
117{
118	return !list_empty(&q->task_list);
119}
120
121extern void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
122extern void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait);
123extern void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
124
125static inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new)
126{
127	list_add(&new->task_list, &head->task_list);
128}
129
130/*
131 * Used for wake-one threads:
132 */
133static inline void __add_wait_queue_exclusive(wait_queue_head_t *q,
134					      wait_queue_t *wait)
135{
136	wait->flags |= WQ_FLAG_EXCLUSIVE;
137	__add_wait_queue(q, wait);
138}
139
140static inline void __add_wait_queue_tail(wait_queue_head_t *head,
141					 wait_queue_t *new)
142{
143	list_add_tail(&new->task_list, &head->task_list);
144}
145
146static inline void __add_wait_queue_tail_exclusive(wait_queue_head_t *q,
147					      wait_queue_t *wait)
148{
149	wait->flags |= WQ_FLAG_EXCLUSIVE;
150	__add_wait_queue_tail(q, wait);
151}
152
153static inline void __remove_wait_queue(wait_queue_head_t *head,
154							wait_queue_t *old)
155{
156	list_del(&old->task_list);
157}
158
159void __wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *key);
160void __wake_up_locked_key(wait_queue_head_t *q, unsigned int mode, void *key);
161void __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode, int nr,
162			void *key);
163void __wake_up_locked(wait_queue_head_t *q, unsigned int mode);
164void __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr);
165void __wake_up_bit(wait_queue_head_t *, void *, int);
166int __wait_on_bit(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned);
167int __wait_on_bit_lock(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned);
168void wake_up_bit(void *, int);
169int out_of_line_wait_on_bit(void *, int, int (*)(void *), unsigned);
170int out_of_line_wait_on_bit_lock(void *, int, int (*)(void *), unsigned);
171wait_queue_head_t *bit_waitqueue(void *, int);
172
173#define wake_up(x)			__wake_up(x, TASK_NORMAL, 1, NULL)
174#define wake_up_nr(x, nr)		__wake_up(x, TASK_NORMAL, nr, NULL)
175#define wake_up_all(x)			__wake_up(x, TASK_NORMAL, 0, NULL)
176#define wake_up_locked(x)		__wake_up_locked((x), TASK_NORMAL)
177
178#define wake_up_interruptible(x)	__wake_up(x, TASK_INTERRUPTIBLE, 1, NULL)
179#define wake_up_interruptible_nr(x, nr)	__wake_up(x, TASK_INTERRUPTIBLE, nr, NULL)
180#define wake_up_interruptible_all(x)	__wake_up(x, TASK_INTERRUPTIBLE, 0, NULL)
181#define wake_up_interruptible_sync(x)	__wake_up_sync((x), TASK_INTERRUPTIBLE, 1)
182
183/*
184 * Wakeup macros to be used to report events to the targets.
185 */
186#define wake_up_poll(x, m)				\
187	__wake_up(x, TASK_NORMAL, 1, (void *) (m))
188#define wake_up_locked_poll(x, m)				\
189	__wake_up_locked_key((x), TASK_NORMAL, (void *) (m))
190#define wake_up_interruptible_poll(x, m)			\
191	__wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m))
192#define wake_up_interruptible_sync_poll(x, m)				\
193	__wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m))
194
195#define __wait_event(wq, condition) 					\
196do {									\
197	DEFINE_WAIT(__wait);						\
198									\
199	for (;;) {							\
200		prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE);	\
201		if (condition)						\
202			break;						\
203		schedule();						\
204	}								\
205	finish_wait(&wq, &__wait);					\
206} while (0)
207
208/**
209 * wait_event - sleep until a condition gets true
210 * @wq: the waitqueue to wait on
211 * @condition: a C expression for the event to wait for
212 *
213 * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
214 * @condition evaluates to true. The @condition is checked each time
215 * the waitqueue @wq is woken up.
216 *
217 * wake_up() has to be called after changing any variable that could
218 * change the result of the wait condition.
219 */
220#define wait_event(wq, condition) 					\
221do {									\
222	if (condition)	 						\
223		break;							\
224	__wait_event(wq, condition);					\
225} while (0)
226
227#define __wait_event_timeout(wq, condition, ret)			\
228do {									\
229	DEFINE_WAIT(__wait);						\
230									\
231	for (;;) {							\
232		prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE);	\
233		if (condition)						\
234			break;						\
235		ret = schedule_timeout(ret);				\
236		if (!ret)						\
237			break;						\
238	}								\
239	finish_wait(&wq, &__wait);					\
240} while (0)
241
242/**
243 * wait_event_timeout - sleep until a condition gets true or a timeout elapses
244 * @wq: the waitqueue to wait on
245 * @condition: a C expression for the event to wait for
246 * @timeout: timeout, in jiffies
247 *
248 * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
249 * @condition evaluates to true. The @condition is checked each time
250 * the waitqueue @wq is woken up.
251 *
252 * wake_up() has to be called after changing any variable that could
253 * change the result of the wait condition.
254 *
255 * The function returns 0 if the @timeout elapsed, and the remaining
256 * jiffies if the condition evaluated to true before the timeout elapsed.
257 */
258#define wait_event_timeout(wq, condition, timeout)			\
259({									\
260	long __ret = timeout;						\
261	if (!(condition)) 						\
262		__wait_event_timeout(wq, condition, __ret);		\
263	__ret;								\
264})
265
266#define __wait_event_interruptible(wq, condition, ret)			\
267do {									\
268	DEFINE_WAIT(__wait);						\
269									\
270	for (;;) {							\
271		prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE);	\
272		if (condition)						\
273			break;						\
274		if (!signal_pending(current)) {				\
275			schedule();					\
276			continue;					\
277		}							\
278		ret = -ERESTARTSYS;					\
279		break;							\
280	}								\
281	finish_wait(&wq, &__wait);					\
282} while (0)
283
284/**
285 * wait_event_interruptible - sleep until a condition gets true
286 * @wq: the waitqueue to wait on
287 * @condition: a C expression for the event to wait for
288 *
289 * The process is put to sleep (TASK_INTERRUPTIBLE) until the
290 * @condition evaluates to true or a signal is received.
291 * The @condition is checked each time the waitqueue @wq is woken up.
292 *
293 * wake_up() has to be called after changing any variable that could
294 * change the result of the wait condition.
295 *
296 * The function will return -ERESTARTSYS if it was interrupted by a
297 * signal and 0 if @condition evaluated to true.
298 */
299#define wait_event_interruptible(wq, condition)				\
300({									\
301	int __ret = 0;							\
302	if (!(condition))						\
303		__wait_event_interruptible(wq, condition, __ret);	\
304	__ret;								\
305})
306
307#define __wait_event_interruptible_timeout(wq, condition, ret)		\
308do {									\
309	DEFINE_WAIT(__wait);						\
310									\
311	for (;;) {							\
312		prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE);	\
313		if (condition)						\
314			break;						\
315		if (!signal_pending(current)) {				\
316			ret = schedule_timeout(ret);			\
317			if (!ret)					\
318				break;					\
319			continue;					\
320		}							\
321		ret = -ERESTARTSYS;					\
322		break;							\
323	}								\
324	finish_wait(&wq, &__wait);					\
325} while (0)
326
327/**
328 * wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses
329 * @wq: the waitqueue to wait on
330 * @condition: a C expression for the event to wait for
331 * @timeout: timeout, in jiffies
332 *
333 * The process is put to sleep (TASK_INTERRUPTIBLE) until the
334 * @condition evaluates to true or a signal is received.
335 * The @condition is checked each time the waitqueue @wq is woken up.
336 *
337 * wake_up() has to be called after changing any variable that could
338 * change the result of the wait condition.
339 *
340 * The function returns 0 if the @timeout elapsed, -ERESTARTSYS if it
341 * was interrupted by a signal, and the remaining jiffies otherwise
342 * if the condition evaluated to true before the timeout elapsed.
343 */
344#define wait_event_interruptible_timeout(wq, condition, timeout)	\
345({									\
346	long __ret = timeout;						\
347	if (!(condition))						\
348		__wait_event_interruptible_timeout(wq, condition, __ret); \
349	__ret;								\
350})
351
352#define __wait_event_interruptible_exclusive(wq, condition, ret)	\
353do {									\
354	DEFINE_WAIT(__wait);						\
355									\
356	for (;;) {							\
357		prepare_to_wait_exclusive(&wq, &__wait,			\
358					TASK_INTERRUPTIBLE);		\
359		if (condition) {					\
360			finish_wait(&wq, &__wait);			\
361			break;						\
362		}							\
363		if (!signal_pending(current)) {				\
364			schedule();					\
365			continue;					\
366		}							\
367		ret = -ERESTARTSYS;					\
368		abort_exclusive_wait(&wq, &__wait, 			\
369				TASK_INTERRUPTIBLE, NULL);		\
370		break;							\
371	}								\
372} while (0)
373
374#define wait_event_interruptible_exclusive(wq, condition)		\
375({									\
376	int __ret = 0;							\
377	if (!(condition))						\
378		__wait_event_interruptible_exclusive(wq, condition, __ret);\
379	__ret;								\
380})
381
382
383#define __wait_event_interruptible_locked(wq, condition, exclusive, irq) \
384({									\
385	int __ret = 0;							\
386	DEFINE_WAIT(__wait);						\
387	if (exclusive)							\
388		__wait.flags |= WQ_FLAG_EXCLUSIVE;			\
389	do {								\
390		if (likely(list_empty(&__wait.task_list)))		\
391			__add_wait_queue_tail(&(wq), &__wait);		\
392		set_current_state(TASK_INTERRUPTIBLE);			\
393		if (signal_pending(current)) {				\
394			__ret = -ERESTARTSYS;				\
395			break;						\
396		}							\
397		if (irq)						\
398			spin_unlock_irq(&(wq).lock);			\
399		else							\
400			spin_unlock(&(wq).lock);			\
401		schedule();						\
402		if (irq)						\
403			spin_lock_irq(&(wq).lock);			\
404		else							\
405			spin_lock(&(wq).lock);				\
406	} while (!(condition));						\
407	__remove_wait_queue(&(wq), &__wait);				\
408	__set_current_state(TASK_RUNNING);				\
409	__ret;								\
410})
411
412
413/**
414 * wait_event_interruptible_locked - sleep until a condition gets true
415 * @wq: the waitqueue to wait on
416 * @condition: a C expression for the event to wait for
417 *
418 * The process is put to sleep (TASK_INTERRUPTIBLE) until the
419 * @condition evaluates to true or a signal is received.
420 * The @condition is checked each time the waitqueue @wq is woken up.
421 *
422 * It must be called with wq.lock being held.  This spinlock is
423 * unlocked while sleeping but @condition testing is done while lock
424 * is held and when this macro exits the lock is held.
425 *
426 * The lock is locked/unlocked using spin_lock()/spin_unlock()
427 * functions which must match the way they are locked/unlocked outside
428 * of this macro.
429 *
430 * wake_up_locked() has to be called after changing any variable that could
431 * change the result of the wait condition.
432 *
433 * The function will return -ERESTARTSYS if it was interrupted by a
434 * signal and 0 if @condition evaluated to true.
435 */
436#define wait_event_interruptible_locked(wq, condition)			\
437	((condition)							\
438	 ? 0 : __wait_event_interruptible_locked(wq, condition, 0, 0))
439
440/**
441 * wait_event_interruptible_locked_irq - sleep until a condition gets true
442 * @wq: the waitqueue to wait on
443 * @condition: a C expression for the event to wait for
444 *
445 * The process is put to sleep (TASK_INTERRUPTIBLE) until the
446 * @condition evaluates to true or a signal is received.
447 * The @condition is checked each time the waitqueue @wq is woken up.
448 *
449 * It must be called with wq.lock being held.  This spinlock is
450 * unlocked while sleeping but @condition testing is done while lock
451 * is held and when this macro exits the lock is held.
452 *
453 * The lock is locked/unlocked using spin_lock_irq()/spin_unlock_irq()
454 * functions which must match the way they are locked/unlocked outside
455 * of this macro.
456 *
457 * wake_up_locked() has to be called after changing any variable that could
458 * change the result of the wait condition.
459 *
460 * The function will return -ERESTARTSYS if it was interrupted by a
461 * signal and 0 if @condition evaluated to true.
462 */
463#define wait_event_interruptible_locked_irq(wq, condition)		\
464	((condition)							\
465	 ? 0 : __wait_event_interruptible_locked(wq, condition, 0, 1))
466
467/**
468 * wait_event_interruptible_exclusive_locked - sleep exclusively until a condition gets true
469 * @wq: the waitqueue to wait on
470 * @condition: a C expression for the event to wait for
471 *
472 * The process is put to sleep (TASK_INTERRUPTIBLE) until the
473 * @condition evaluates to true or a signal is received.
474 * The @condition is checked each time the waitqueue @wq is woken up.
475 *
476 * It must be called with wq.lock being held.  This spinlock is
477 * unlocked while sleeping but @condition testing is done while lock
478 * is held and when this macro exits the lock is held.
479 *
480 * The lock is locked/unlocked using spin_lock()/spin_unlock()
481 * functions which must match the way they are locked/unlocked outside
482 * of this macro.
483 *
484 * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
485 * set thus when other process waits process on the list if this
486 * process is awaken further processes are not considered.
487 *
488 * wake_up_locked() has to be called after changing any variable that could
489 * change the result of the wait condition.
490 *
491 * The function will return -ERESTARTSYS if it was interrupted by a
492 * signal and 0 if @condition evaluated to true.
493 */
494#define wait_event_interruptible_exclusive_locked(wq, condition)	\
495	((condition)							\
496	 ? 0 : __wait_event_interruptible_locked(wq, condition, 1, 0))
497
498/**
499 * wait_event_interruptible_exclusive_locked_irq - sleep until a condition gets true
500 * @wq: the waitqueue to wait on
501 * @condition: a C expression for the event to wait for
502 *
503 * The process is put to sleep (TASK_INTERRUPTIBLE) until the
504 * @condition evaluates to true or a signal is received.
505 * The @condition is checked each time the waitqueue @wq is woken up.
506 *
507 * It must be called with wq.lock being held.  This spinlock is
508 * unlocked while sleeping but @condition testing is done while lock
509 * is held and when this macro exits the lock is held.
510 *
511 * The lock is locked/unlocked using spin_lock_irq()/spin_unlock_irq()
512 * functions which must match the way they are locked/unlocked outside
513 * of this macro.
514 *
515 * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
516 * set thus when other process waits process on the list if this
517 * process is awaken further processes are not considered.
518 *
519 * wake_up_locked() has to be called after changing any variable that could
520 * change the result of the wait condition.
521 *
522 * The function will return -ERESTARTSYS if it was interrupted by a
523 * signal and 0 if @condition evaluated to true.
524 */
525#define wait_event_interruptible_exclusive_locked_irq(wq, condition)	\
526	((condition)							\
527	 ? 0 : __wait_event_interruptible_locked(wq, condition, 1, 1))
528
529
530
531#define __wait_event_killable(wq, condition, ret)			\
532do {									\
533	DEFINE_WAIT(__wait);						\
534									\
535	for (;;) {							\
536		prepare_to_wait(&wq, &__wait, TASK_KILLABLE);		\
537		if (condition)						\
538			break;						\
539		if (!fatal_signal_pending(current)) {			\
540			schedule();					\
541			continue;					\
542		}							\
543		ret = -ERESTARTSYS;					\
544		break;							\
545	}								\
546	finish_wait(&wq, &__wait);					\
547} while (0)
548
549/**
550 * wait_event_killable - sleep until a condition gets true
551 * @wq: the waitqueue to wait on
552 * @condition: a C expression for the event to wait for
553 *
554 * The process is put to sleep (TASK_KILLABLE) until the
555 * @condition evaluates to true or a signal is received.
556 * The @condition is checked each time the waitqueue @wq is woken up.
557 *
558 * wake_up() has to be called after changing any variable that could
559 * change the result of the wait condition.
560 *
561 * The function will return -ERESTARTSYS if it was interrupted by a
562 * signal and 0 if @condition evaluated to true.
563 */
564#define wait_event_killable(wq, condition)				\
565({									\
566	int __ret = 0;							\
567	if (!(condition))						\
568		__wait_event_killable(wq, condition, __ret);		\
569	__ret;								\
570})
571
572/*
573 * These are the old interfaces to sleep waiting for an event.
574 * They are racy.  DO NOT use them, use the wait_event* interfaces above.
575 * We plan to remove these interfaces.
576 */
577extern void sleep_on(wait_queue_head_t *q);
578extern long sleep_on_timeout(wait_queue_head_t *q,
579				      signed long timeout);
580extern void interruptible_sleep_on(wait_queue_head_t *q);
581extern long interruptible_sleep_on_timeout(wait_queue_head_t *q,
582					   signed long timeout);
583
584/*
585 * Waitqueues which are removed from the waitqueue_head at wakeup time
586 */
587void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state);
588void prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state);
589void finish_wait(wait_queue_head_t *q, wait_queue_t *wait);
590void abort_exclusive_wait(wait_queue_head_t *q, wait_queue_t *wait,
591			unsigned int mode, void *key);
592int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
593long wait_woken(wait_queue_t *wait, unsigned mode, long timeout);
594int woken_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
595int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
596
597#define DEFINE_WAIT_FUNC(name, function)				\
598	wait_queue_t name = {						\
599		.private	= current,				\
600		.func		= function,				\
601		.task_list	= LIST_HEAD_INIT((name).task_list),	\
602	}
603
604#define DEFINE_WAIT(name) DEFINE_WAIT_FUNC(name, autoremove_wake_function)
605
606#define DEFINE_WAIT_BIT(name, word, bit)				\
607	struct wait_bit_queue name = {					\
608		.key = __WAIT_BIT_KEY_INITIALIZER(word, bit),		\
609		.wait	= {						\
610			.private	= current,			\
611			.func		= wake_bit_function,		\
612			.task_list	=				\
613				LIST_HEAD_INIT((name).wait.task_list),	\
614		},							\
615	}
616
617#define init_wait(wait)							\
618	do {								\
619		(wait)->private = current;				\
620		(wait)->func = autoremove_wake_function;		\
621		INIT_LIST_HEAD(&(wait)->task_list);			\
622		(wait)->flags = 0;					\
623	} while (0)
624
625/**
626 * wait_on_bit - wait for a bit to be cleared
627 * @word: the word being waited on, a kernel virtual address
628 * @bit: the bit of the word being waited on
629 * @action: the function used to sleep, which may take special actions
630 * @mode: the task state to sleep in
631 *
632 * There is a standard hashed waitqueue table for generic use. This
633 * is the part of the hashtable's accessor API that waits on a bit.
634 * For instance, if one were to have waiters on a bitflag, one would
635 * call wait_on_bit() in threads waiting for the bit to clear.
636 * One uses wait_on_bit() where one is waiting for the bit to clear,
637 * but has no intention of setting it.
638 */
639static inline int wait_on_bit(void *word, int bit,
640				int (*action)(void *), unsigned mode)
641{
642	if (!test_bit(bit, word))
643		return 0;
644	return out_of_line_wait_on_bit(word, bit, action, mode);
645}
646
647/**
648 * wait_on_bit_lock - wait for a bit to be cleared, when wanting to set it
649 * @word: the word being waited on, a kernel virtual address
650 * @bit: the bit of the word being waited on
651 * @action: the function used to sleep, which may take special actions
652 * @mode: the task state to sleep in
653 *
654 * There is a standard hashed waitqueue table for generic use. This
655 * is the part of the hashtable's accessor API that waits on a bit
656 * when one intends to set it, for instance, trying to lock bitflags.
657 * For instance, if one were to have waiters trying to set bitflag
658 * and waiting for it to clear before setting it, one would call
659 * wait_on_bit() in threads waiting to be able to set the bit.
660 * One uses wait_on_bit_lock() where one is waiting for the bit to
661 * clear with the intention of setting it, and when done, clearing it.
662 */
663static inline int wait_on_bit_lock(void *word, int bit,
664				int (*action)(void *), unsigned mode)
665{
666	if (!test_and_set_bit(bit, word))
667		return 0;
668	return out_of_line_wait_on_bit_lock(word, bit, action, mode);
669}
670
671#endif /* __KERNEL__ */
672
673#endif
674