summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRussell King <rmk@arm.linux.org.uk>2004-09-26 17:23:19 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-09-26 17:23:19 -0700
commit9192a60bd5cadea1425bd408bab053a8556ff928 (patch)
treea292c5884034d697c3d7c5af30b19a397638c506 /include
parentc160629a8752cefd12f482a9f505b877b6af8ad3 (diff)
[PATCH] Add wait_event_timeout()
There appears to be one case missing from the wait_event() family - the uninterruptible timeout wait. The following patch adds this. This wait is particularly useful when (eg) you wish to pass work off to an interrupt handler to perform, but also want to know if the hardware has decided to go gaga under you. You don't want to sit around waiting for something that'll never happen - you want to go and wack the gremlin which caused the failure and retry. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/wait.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 4417f800a639..21cd4df67b24 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -156,6 +156,29 @@ do { \
__wait_event(wq, condition); \
} while (0)
+#define __wait_event_timeout(wq, condition, ret) \
+do { \
+ DEFINE_WAIT(__wait); \
+ \
+ for (;;) { \
+ prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \
+ if (condition) \
+ break; \
+ ret = schedule_timeout(ret); \
+ if (!ret) \
+ break; \
+ } \
+ finish_wait(&wq, &__wait); \
+} while (0)
+
+#define wait_event_timeout(wq, condition, timeout) \
+({ \
+ long __ret = timeout; \
+ if (!(condition)) \
+ __wait_event_timeout(wq, condition, __ret); \
+ __ret; \
+})
+
#define __wait_event_interruptible(wq, condition, ret) \
do { \
DEFINE_WAIT(__wait); \