]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/linux/wait.h
sched/wait: Collapse __wait_event_interruptible_timeout()
[karo-tx-linux.git] / include / linux / wait.h
index 68e3a628e1578440928cde498dd357ec7b0447d5..a79fb15c1dd445068496058436bad16d52eedf41 100644 (file)
@@ -247,17 +247,9 @@ do {                                                                       \
 } while (0)
 
 #define __wait_event_timeout(wq, condition, ret)                       \
-do {                                                                   \
-       DEFINE_WAIT(__wait);                                            \
-                                                                       \
-       for (;;) {                                                      \
-               prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE);    \
-               if (___wait_cond_timeout(condition, ret))               \
-                       break;                                          \
-               ret = schedule_timeout(ret);                            \
-       }                                                               \
-       finish_wait(&wq, &__wait);                                      \
-} while (0)
+       ___wait_event(wq, ___wait_cond_timeout(condition, ret),         \
+                     TASK_UNINTERRUPTIBLE, 0, ret,                     \
+                     ret = schedule_timeout(ret))
 
 /**
  * wait_event_timeout - sleep until a condition gets true or a timeout elapses
@@ -285,21 +277,8 @@ do {                                                                       \
 })
 
 #define __wait_event_interruptible(wq, condition, ret)                 \
-do {                                                                   \
-       DEFINE_WAIT(__wait);                                            \
-                                                                       \
-       for (;;) {                                                      \
-               prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE);      \
-               if (condition)                                          \
-                       break;                                          \
-               if (signal_pending(current)) {                          \
-                       ret = -ERESTARTSYS;                             \
-                       break;                                          \
-               }                                                       \
-               schedule();                                             \
-       }                                                               \
-       finish_wait(&wq, &__wait);                                      \
-} while (0)
+       ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, ret,        \
+                     schedule())
 
 /**
  * wait_event_interruptible - sleep until a condition gets true
@@ -325,21 +304,9 @@ do {                                                                       \
 })
 
 #define __wait_event_interruptible_timeout(wq, condition, ret)         \
-do {                                                                   \
-       DEFINE_WAIT(__wait);                                            \
-                                                                       \
-       for (;;) {                                                      \
-               prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE);      \
-               if (___wait_cond_timeout(condition, ret))               \
-                       break;                                          \
-               if (signal_pending(current)) {                          \
-                       ret = -ERESTARTSYS;                             \
-                       break;                                          \
-               }                                                       \
-               ret = schedule_timeout(ret);                            \
-       }                                                               \
-       finish_wait(&wq, &__wait);                                      \
-} while (0)
+       ___wait_event(wq, ___wait_cond_timeout(condition, ret),         \
+                     TASK_INTERRUPTIBLE, 0, ret,                       \
+                     ret = schedule_timeout(ret))
 
 /**
  * wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses