aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/wait.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/wait.h')
-rw-r--r--include/linux/wait.h24
1 files changed, 11 insertions, 13 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h
index ccf0c529fd37..b2afd665e4ea 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -179,6 +179,14 @@ wait_queue_head_t *bit_waitqueue(void *, int);
179#define wake_up_interruptible_sync_poll(x, m) \ 179#define wake_up_interruptible_sync_poll(x, m) \
180 __wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m)) 180 __wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m))
181 181
182#define ___wait_cond_timeout(condition, ret) \
183({ \
184 bool __cond = (condition); \
185 if (__cond && !ret) \
186 ret = 1; \
187 __cond || !ret; \
188})
189
182#define __wait_event(wq, condition) \ 190#define __wait_event(wq, condition) \
183do { \ 191do { \
184 DEFINE_WAIT(__wait); \ 192 DEFINE_WAIT(__wait); \
@@ -217,14 +225,10 @@ do { \
217 \ 225 \
218 for (;;) { \ 226 for (;;) { \
219 prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \ 227 prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \
220 if (condition) \ 228 if (___wait_cond_timeout(condition, ret)) \
221 break; \ 229 break; \
222 ret = schedule_timeout(ret); \ 230 ret = schedule_timeout(ret); \
223 if (!ret) \
224 break; \
225 } \ 231 } \
226 if (!ret && (condition)) \
227 ret = 1; \
228 finish_wait(&wq, &__wait); \ 232 finish_wait(&wq, &__wait); \
229} while (0) 233} while (0)
230 234
@@ -299,18 +303,14 @@ do { \
299 \ 303 \
300 for (;;) { \ 304 for (;;) { \
301 prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \ 305 prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
302 if (condition) \ 306 if (___wait_cond_timeout(condition, ret)) \
303 break; \ 307 break; \
304 if (signal_pending(current)) { \ 308 if (signal_pending(current)) { \
305 ret = -ERESTARTSYS; \ 309 ret = -ERESTARTSYS; \
306 break; \ 310 break; \
307 } \ 311 } \
308 ret = schedule_timeout(ret); \ 312 ret = schedule_timeout(ret); \
309 if (!ret) \
310 break; \
311 } \ 313 } \
312 if (!ret && (condition)) \
313 ret = 1; \
314 finish_wait(&wq, &__wait); \ 314 finish_wait(&wq, &__wait); \
315} while (0) 315} while (0)
316 316
@@ -815,7 +815,7 @@ do { \
815 \ 815 \
816 for (;;) { \ 816 for (;;) { \
817 prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \ 817 prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
818 if (condition) \ 818 if (___wait_cond_timeout(condition, ret)) \
819 break; \ 819 break; \
820 if (signal_pending(current)) { \ 820 if (signal_pending(current)) { \
821 ret = -ERESTARTSYS; \ 821 ret = -ERESTARTSYS; \
@@ -824,8 +824,6 @@ do { \
824 spin_unlock_irq(&lock); \ 824 spin_unlock_irq(&lock); \
825 ret = schedule_timeout(ret); \ 825 ret = schedule_timeout(ret); \
826 spin_lock_irq(&lock); \ 826 spin_lock_irq(&lock); \
827 if (!ret) \
828 break; \
829 } \ 827 } \
830 finish_wait(&wq, &__wait); \ 828 finish_wait(&wq, &__wait); \
831} while (0) 829} while (0)