OSDN Git Service

Add wait_var_event_interruptible()
authorDavid Howells <dhowells@redhat.com>
Fri, 3 May 2019 17:30:33 +0000 (18:30 +0100)
committerDavid Howells <dhowells@redhat.com>
Wed, 15 May 2019 16:35:54 +0000 (17:35 +0100)
Add wait_var_event_interruptible() to allow interruptible waits for events.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
include/linux/wait_bit.h

index 2b0072f..7dec36a 100644 (file)
@@ -305,6 +305,19 @@ do {                                                                       \
        __ret;                                                          \
 })
 
+#define __wait_var_event_interruptible(var, condition)                 \
+       ___wait_var_event(var, condition, TASK_INTERRUPTIBLE, 0, 0,     \
+                         schedule())
+
+#define wait_var_event_interruptible(var, condition)                   \
+({                                                                     \
+       int __ret = 0;                                                  \
+       might_sleep();                                                  \
+       if (!(condition))                                               \
+               __ret = __wait_var_event_interruptible(var, condition); \
+       __ret;                                                          \
+})
+
 /**
  * clear_and_wake_up_bit - clear a bit and wake up anyone waiting on that bit
  *