diff options
Diffstat (limited to 'include/linux/wait.h')
-rw-r--r-- | include/linux/wait.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h index 2232ed16635a..2db83349865b 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h | |||
@@ -267,6 +267,21 @@ do { \ | |||
267 | __wait_event(wq, condition); \ | 267 | __wait_event(wq, condition); \ |
268 | } while (0) | 268 | } while (0) |
269 | 269 | ||
270 | #define __io_wait_event(wq, condition) \ | ||
271 | (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0, \ | ||
272 | io_schedule()) | ||
273 | |||
274 | /* | ||
275 | * io_wait_event() -- like wait_event() but with io_schedule() | ||
276 | */ | ||
277 | #define io_wait_event(wq, condition) \ | ||
278 | do { \ | ||
279 | might_sleep(); \ | ||
280 | if (condition) \ | ||
281 | break; \ | ||
282 | __io_wait_event(wq, condition); \ | ||
283 | } while (0) | ||
284 | |||
270 | #define __wait_event_freezable(wq, condition) \ | 285 | #define __wait_event_freezable(wq, condition) \ |
271 | ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0, \ | 286 | ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0, \ |
272 | schedule(); try_to_freeze()) | 287 | schedule(); try_to_freeze()) |
@@ -363,7 +378,6 @@ do { \ | |||
363 | */ | 378 | */ |
364 | #define wait_event_cmd(wq, condition, cmd1, cmd2) \ | 379 | #define wait_event_cmd(wq, condition, cmd1, cmd2) \ |
365 | do { \ | 380 | do { \ |
366 | might_sleep(); \ | ||
367 | if (condition) \ | 381 | if (condition) \ |
368 | break; \ | 382 | break; \ |
369 | __wait_event_cmd(wq, condition, cmd1, cmd2); \ | 383 | __wait_event_cmd(wq, condition, cmd1, cmd2); \ |
@@ -991,6 +1005,32 @@ wait_on_bit_io(void *word, int bit, unsigned mode) | |||
991 | } | 1005 | } |
992 | 1006 | ||
993 | /** | 1007 | /** |
1008 | * wait_on_bit_timeout - wait for a bit to be cleared or a timeout elapses | ||
1009 | * @word: the word being waited on, a kernel virtual address | ||
1010 | * @bit: the bit of the word being waited on | ||
1011 | * @mode: the task state to sleep in | ||
1012 | * @timeout: timeout, in jiffies | ||
1013 | * | ||
1014 | * Use the standard hashed waitqueue table to wait for a bit | ||
1015 | * to be cleared. This is similar to wait_on_bit(), except also takes a | ||
1016 | * timeout parameter. | ||
1017 | * | ||
1018 | * Returned value will be zero if the bit was cleared before the | ||
1019 | * @timeout elapsed, or non-zero if the @timeout elapsed or process | ||
1020 | * received a signal and the mode permitted wakeup on that signal. | ||
1021 | */ | ||
1022 | static inline int | ||
1023 | wait_on_bit_timeout(void *word, int bit, unsigned mode, unsigned long timeout) | ||
1024 | { | ||
1025 | might_sleep(); | ||
1026 | if (!test_bit(bit, word)) | ||
1027 | return 0; | ||
1028 | return out_of_line_wait_on_bit_timeout(word, bit, | ||
1029 | bit_wait_timeout, | ||
1030 | mode, timeout); | ||
1031 | } | ||
1032 | |||
1033 | /** | ||
994 | * wait_on_bit_action - wait for a bit to be cleared | 1034 | * wait_on_bit_action - wait for a bit to be cleared |
995 | * @word: the word being waited on, a kernel virtual address | 1035 | * @word: the word being waited on, a kernel virtual address |
996 | * @bit: the bit of the word being waited on | 1036 | * @bit: the bit of the word being waited on |