]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/linux/wait.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
[karo-tx-linux.git] / include / linux / wait.h
index db076ca7f11da03f474be67f792e1189b96425eb..b289c96151eec4395197236f567b957687565130 100644 (file)
 #include <asm/current.h>
 #include <uapi/linux/wait.h>
 
-typedef struct __wait_queue wait_queue_t;
-typedef int (*wait_queue_func_t)(wait_queue_t *wait, unsigned mode, int flags, void *key);
-int default_wake_function(wait_queue_t *wait, unsigned mode, int flags, void *key);
+typedef struct wait_queue_entry wait_queue_entry_t;
 
-/* __wait_queue::flags */
+typedef int (*wait_queue_func_t)(struct wait_queue_entry *wq_entry, unsigned mode, int flags, void *key);
+int default_wake_function(struct wait_queue_entry *wq_entry, unsigned mode, int flags, void *key);
+
+/* wait_queue_entry::flags */
 #define WQ_FLAG_EXCLUSIVE      0x01
 #define WQ_FLAG_WOKEN          0x02
 
-struct __wait_queue {
+/*
+ * A single wait-queue entry structure:
+ */
+struct wait_queue_entry {
        unsigned int            flags;
        void                    *private;
        wait_queue_func_t       func;
-       struct list_head        task_list;
-};
-
-struct wait_bit_key {
-       void                    *flags;
-       int                     bit_nr;
-#define WAIT_ATOMIC_T_BIT_NR   -1
-       unsigned long           timeout;
+       struct list_head        entry;
 };
 
-struct wait_bit_queue {
-       struct wait_bit_key     key;
-       wait_queue_t            wait;
-};
-
-struct __wait_queue_head {
+struct wait_queue_head {
        spinlock_t              lock;
-       struct list_head        task_list;
+       struct list_head        head;
 };
-typedef struct __wait_queue_head wait_queue_head_t;
+typedef struct wait_queue_head wait_queue_head_t;
 
 struct task_struct;
 
@@ -49,82 +41,76 @@ struct task_struct;
  * Macros for declaration and initialisaton of the datatypes
  */
 
-#define __WAITQUEUE_INITIALIZER(name, tsk) {                           \
-       .private        = tsk,                                          \
-       .func           = default_wake_function,                        \
-       .task_list      = { NULL, NULL } }
+#define __WAITQUEUE_INITIALIZER(name, tsk) {                                   \
+       .private        = tsk,                                                  \
+       .func           = default_wake_function,                                \
+       .entry          = { NULL, NULL } }
 
-#define DECLARE_WAITQUEUE(name, tsk)                                   \
-       wait_queue_t name = __WAITQUEUE_INITIALIZER(name, tsk)
+#define DECLARE_WAITQUEUE(name, tsk)                                           \
+       struct wait_queue_entry name = __WAITQUEUE_INITIALIZER(name, tsk)
 
-#define __WAIT_QUEUE_HEAD_INITIALIZER(name) {                          \
-       .lock           = __SPIN_LOCK_UNLOCKED(name.lock),              \
-       .task_list      = { &(name).task_list, &(name).task_list } }
+#define __WAIT_QUEUE_HEAD_INITIALIZER(name) {                                  \
+       .lock           = __SPIN_LOCK_UNLOCKED(name.lock),                      \
+       .head           = { &(name).head, &(name).head } }
 
 #define DECLARE_WAIT_QUEUE_HEAD(name) \
-       wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
-
-#define __WAIT_BIT_KEY_INITIALIZER(word, bit)                          \
-       { .flags = word, .bit_nr = bit, }
+       struct wait_queue_head name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
 
-#define __WAIT_ATOMIC_T_KEY_INITIALIZER(p)                             \
-       { .flags = p, .bit_nr = WAIT_ATOMIC_T_BIT_NR, }
+extern void __init_waitqueue_head(struct wait_queue_head *wq_head, const char *name, struct lock_class_key *);
 
-extern void __init_waitqueue_head(wait_queue_head_t *q, const char *name, struct lock_class_key *);
-
-#define init_waitqueue_head(q)                         \
-       do {                                            \
-               static struct lock_class_key __key;     \
-                                                       \
-               __init_waitqueue_head((q), #q, &__key); \
+#define init_waitqueue_head(wq_head)                                           \
+       do {                                                                    \
+               static struct lock_class_key __key;                             \
+                                                                               \
+               __init_waitqueue_head((wq_head), #wq_head, &__key);             \
        } while (0)
 
 #ifdef CONFIG_LOCKDEP
 # define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) \
        ({ init_waitqueue_head(&name); name; })
 # define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) \
-       wait_queue_head_t name = __WAIT_QUEUE_HEAD_INIT_ONSTACK(name)
+       struct wait_queue_head name = __WAIT_QUEUE_HEAD_INIT_ONSTACK(name)
 #else
 # define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) DECLARE_WAIT_QUEUE_HEAD(name)
 #endif
 
-static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p)
+static inline void init_waitqueue_entry(struct wait_queue_entry *wq_entry, struct task_struct *p)
 {
-       q->flags        = 0;
-       q->private      = p;
-       q->func         = default_wake_function;
+       wq_entry->flags         = 0;
+       wq_entry->private       = p;
+       wq_entry->func          = default_wake_function;
 }
 
 static inline void
-init_waitqueue_func_entry(wait_queue_t *q, wait_queue_func_t func)
+init_waitqueue_func_entry(struct wait_queue_entry *wq_entry, wait_queue_func_t func)
 {
-       q->flags        = 0;
-       q->private      = NULL;
-       q->func         = func;
+       wq_entry->flags         = 0;
+       wq_entry->private       = NULL;
+       wq_entry->func          = func;
 }
 
 /**
  * waitqueue_active -- locklessly test for waiters on the queue
- * @q: the waitqueue to test for waiters
+ * @wq_head: the waitqueue to test for waiters
  *
  * returns true if the wait list is not empty
  *
  * NOTE: this function is lockless and requires care, incorrect usage _will_
  * lead to sporadic and non-obvious failure.
  *
- * Use either while holding wait_queue_head_t::lock or when used for wakeups
+ * Use either while holding wait_queue_head::lock or when used for wakeups
  * with an extra smp_mb() like:
  *
  *      CPU0 - waker                    CPU1 - waiter
  *
  *                                      for (;;) {
- *      @cond = true;                     prepare_to_wait(&wq, &wait, state);
+ *      @cond = true;                     prepare_to_wait(&wq_head, &wait, state);
  *      smp_mb();                         // smp_mb() from set_current_state()
- *      if (waitqueue_active(wq))         if (@cond)
- *        wake_up(wq);                      break;
+ *      if (waitqueue_active(wq_head))         if (@cond)
+ *        wake_up(wq_head);                      break;
  *                                        schedule();
  *                                      }
- *                                      finish_wait(&wq, &wait);
+ *                                      finish_wait(&wq_head, &wait);
  *
  * Because without the explicit smp_mb() it's possible for the
  * waitqueue_active() load to get hoisted over the @cond store such that we'll
@@ -133,20 +119,20 @@ init_waitqueue_func_entry(wait_queue_t *q, wait_queue_func_t func)
  * Also note that this 'optimization' trades a spin_lock() for an smp_mb(),
  * which (when the lock is uncontended) are of roughly equal cost.
  */
-static inline int waitqueue_active(wait_queue_head_t *q)
+static inline int waitqueue_active(struct wait_queue_head *wq_head)
 {
-       return !list_empty(&q->task_list);
+       return !list_empty(&wq_head->head);
 }
 
 /**
  * wq_has_sleeper - check if there are any waiting processes
- * @wq: wait queue head
+ * @wq_head: wait queue head
  *
- * Returns true if wq has waiting processes
+ * Returns true if wq_head has waiting processes
  *
  * Please refer to the comment for waitqueue_active.
  */
-static inline bool wq_has_sleeper(wait_queue_head_t *wq)
+static inline bool wq_has_sleeper(struct wait_queue_head *wq_head)
 {
        /*
         * We need to be sure we are in sync with the
@@ -156,63 +142,51 @@ static inline bool wq_has_sleeper(wait_queue_head_t *wq)
         * waiting side.
         */
        smp_mb();
-       return waitqueue_active(wq);
+       return waitqueue_active(wq_head);
 }
 
-extern void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
-extern void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait);
-extern void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
+extern void add_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
+extern void add_wait_queue_exclusive(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
+extern void remove_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
 
-static inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new)
+static inline void __add_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
 {
-       list_add(&new->task_list, &head->task_list);
+       list_add(&wq_entry->entry, &wq_head->head);
 }
 
 /*
  * Used for wake-one threads:
  */
 static inline void
-__add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait)
+__add_wait_queue_exclusive(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
 {
-       wait->flags |= WQ_FLAG_EXCLUSIVE;
-       __add_wait_queue(q, wait);
+       wq_entry->flags |= WQ_FLAG_EXCLUSIVE;
+       __add_wait_queue(wq_head, wq_entry);
 }
 
-static inline void __add_wait_queue_tail(wait_queue_head_t *head,
-                                        wait_queue_t *new)
+static inline void __add_wait_queue_entry_tail(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
 {
-       list_add_tail(&new->task_list, &head->task_list);
+       list_add_tail(&wq_entry->entry, &wq_head->head);
 }
 
 static inline void
-__add_wait_queue_tail_exclusive(wait_queue_head_t *q, wait_queue_t *wait)
+__add_wait_queue_entry_tail_exclusive(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
 {
-       wait->flags |= WQ_FLAG_EXCLUSIVE;
-       __add_wait_queue_tail(q, wait);
+       wq_entry->flags |= WQ_FLAG_EXCLUSIVE;
+       __add_wait_queue_entry_tail(wq_head, wq_entry);
 }
 
 static inline void
-__remove_wait_queue(wait_queue_head_t *head, wait_queue_t *old)
+__remove_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
 {
-       list_del(&old->task_list);
+       list_del(&wq_entry->entry);
 }
 
-typedef int wait_bit_action_f(struct wait_bit_key *, int mode);
-void __wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *key);
-void __wake_up_locked_key(wait_queue_head_t *q, unsigned int mode, void *key);
-void __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode, int nr, void *key);
-void __wake_up_locked(wait_queue_head_t *q, unsigned int mode, int nr);
-void __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr);
-void __wake_up_bit(wait_queue_head_t *, void *, int);
-int __wait_on_bit(wait_queue_head_t *, struct wait_bit_queue *, wait_bit_action_f *, unsigned);
-int __wait_on_bit_lock(wait_queue_head_t *, struct wait_bit_queue *, wait_bit_action_f *, unsigned);
-void wake_up_bit(void *, int);
-void wake_up_atomic_t(atomic_t *);
-int out_of_line_wait_on_bit(void *, int, wait_bit_action_f *, unsigned);
-int out_of_line_wait_on_bit_timeout(void *, int, wait_bit_action_f *, unsigned, unsigned long);
-int out_of_line_wait_on_bit_lock(void *, int, wait_bit_action_f *, unsigned);
-int out_of_line_wait_on_atomic_t(atomic_t *, int (*)(atomic_t *), unsigned);
-wait_queue_head_t *bit_waitqueue(void *, int);
+void __wake_up(struct wait_queue_head *wq_head, unsigned int mode, int nr, void *key);
+void __wake_up_locked_key(struct wait_queue_head *wq_head, unsigned int mode, void *key);
+void __wake_up_sync_key(struct wait_queue_head *wq_head, unsigned int mode, int nr, void *key);
+void __wake_up_locked(struct wait_queue_head *wq_head, unsigned int mode, int nr);
+void __wake_up_sync(struct wait_queue_head *wq_head, unsigned int mode, int nr);
 
 #define wake_up(x)                     __wake_up(x, TASK_NORMAL, 1, NULL)
 #define wake_up_nr(x, nr)              __wake_up(x, TASK_NORMAL, nr, NULL)
@@ -228,28 +202,28 @@ wait_queue_head_t *bit_waitqueue(void *, int);
 /*
  * Wakeup macros to be used to report events to the targets.
  */
-#define wake_up_poll(x, m)                                             \
+#define wake_up_poll(x, m)                                                     \
        __wake_up(x, TASK_NORMAL, 1, (void *) (m))
-#define wake_up_locked_poll(x, m)                                      \
+#define wake_up_locked_poll(x, m)                                              \
        __wake_up_locked_key((x), TASK_NORMAL, (void *) (m))
-#define wake_up_interruptible_poll(x, m)                               \
+#define wake_up_interruptible_poll(x, m)                                       \
        __wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m))
-#define wake_up_interruptible_sync_poll(x, m)                          \
+#define wake_up_interruptible_sync_poll(x, m)                                  \
        __wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m))
 
-#define ___wait_cond_timeout(condition)                                        \
-({                                                                     \
-       bool __cond = (condition);                                      \
-       if (__cond && !__ret)                                           \
-               __ret = 1;                                              \
-       __cond || !__ret;                                               \
+#define ___wait_cond_timeout(condition)                                                \
+({                                                                             \
+       bool __cond = (condition);                                              \
+       if (__cond && !__ret)                                                   \
+               __ret = 1;                                                      \
+       __cond || !__ret;                                                       \
 })
 
-#define ___wait_is_interruptible(state)                                        \
-       (!__builtin_constant_p(state) ||                                \
-               state == TASK_INTERRUPTIBLE || state == TASK_KILLABLE)  \
+#define ___wait_is_interruptible(state)                                                \
+       (!__builtin_constant_p(state) ||                                        \
+               state == TASK_INTERRUPTIBLE || state == TASK_KILLABLE)          \
 
-extern void init_wait_entry(wait_queue_t *__wait, int flags);
+extern void init_wait_entry(struct wait_queue_entry *wq_entry, int flags);
 
 /*
  * The below macro ___wait_event() has an explicit shadow of the __ret
@@ -263,108 +237,108 @@ extern void init_wait_entry(wait_queue_t *__wait, int flags);
  * otherwise.
  */
 
-#define ___wait_event(wq, condition, state, exclusive, ret, cmd)       \
-({                                                                     \
-       __label__ __out;                                                \
-       wait_queue_t __wait;                                            \
-       long __ret = ret;       /* explicit shadow */                   \
-                                                                       \
-       init_wait_entry(&__wait, exclusive ? WQ_FLAG_EXCLUSIVE : 0);    \
-       for (;;) {                                                      \
-               long __int = prepare_to_wait_event(&wq, &__wait, state);\
-                                                                       \
-               if (condition)                                          \
-                       break;                                          \
-                                                                       \
-               if (___wait_is_interruptible(state) && __int) {         \
-                       __ret = __int;                                  \
-                       goto __out;                                     \
-               }                                                       \
-                                                                       \
-               cmd;                                                    \
-       }                                                               \
-       finish_wait(&wq, &__wait);                                      \
-__out: __ret;                                                          \
+#define ___wait_event(wq_head, condition, state, exclusive, ret, cmd)          \
+({                                                                             \
+       __label__ __out;                                                        \
+       struct wait_queue_entry __wq_entry;                                     \
+       long __ret = ret;       /* explicit shadow */                           \
+                                                                               \
+       init_wait_entry(&__wq_entry, exclusive ? WQ_FLAG_EXCLUSIVE : 0);        \
+       for (;;) {                                                              \
+               long __int = prepare_to_wait_event(&wq_head, &__wq_entry, state);\
+                                                                               \
+               if (condition)                                                  \
+                       break;                                                  \
+                                                                               \
+               if (___wait_is_interruptible(state) && __int) {                 \
+                       __ret = __int;                                          \
+                       goto __out;                                             \
+               }                                                               \
+                                                                               \
+               cmd;                                                            \
+       }                                                                       \
+       finish_wait(&wq_head, &__wq_entry);                                     \
+__out: __ret;                                                                  \
 })
 
-#define __wait_event(wq, condition)                                    \
-       (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0,  \
+#define __wait_event(wq_head, condition)                                       \
+       (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0,     \
                            schedule())
 
 /**
  * wait_event - sleep until a condition gets true
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  *
  * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
  * @condition evaluates to true. The @condition is checked each time
- * the waitqueue @wq is woken up.
+ * the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
  */
-#define wait_event(wq, condition)                                      \
-do {                                                                   \
-       might_sleep();                                                  \
-       if (condition)                                                  \
-               break;                                                  \
-       __wait_event(wq, condition);                                    \
+#define wait_event(wq_head, condition)                                         \
+do {                                                                           \
+       might_sleep();                                                          \
+       if (condition)                                                          \
+               break;                                                          \
+       __wait_event(wq_head, condition);                                       \
 } while (0)
 
-#define __io_wait_event(wq, condition)                                 \
-       (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0,  \
+#define __io_wait_event(wq_head, condition)                                    \
+       (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0,     \
                            io_schedule())
 
 /*
  * io_wait_event() -- like wait_event() but with io_schedule()
  */
-#define io_wait_event(wq, condition)                                   \
-do {                                                                   \
-       might_sleep();                                                  \
-       if (condition)                                                  \
-               break;                                                  \
-       __io_wait_event(wq, condition);                                 \
+#define io_wait_event(wq_head, condition)                                      \
+do {                                                                           \
+       might_sleep();                                                          \
+       if (condition)                                                          \
+               break;                                                          \
+       __io_wait_event(wq_head, condition);                                    \
 } while (0)
 
-#define __wait_event_freezable(wq, condition)                          \
-       ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0,          \
+#define __wait_event_freezable(wq_head, condition)                             \
+       ___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0,             \
                            schedule(); try_to_freeze())
 
 /**
  * wait_event_freezable - sleep (or freeze) until a condition gets true
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  *
  * The process is put to sleep (TASK_INTERRUPTIBLE -- so as not to contribute
  * to system load) until the @condition evaluates to true. The
- * @condition is checked each time the waitqueue @wq is woken up.
+ * @condition is checked each time the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
  */
-#define wait_event_freezable(wq, condition)                            \
-({                                                                     \
-       int __ret = 0;                                                  \
-       might_sleep();                                                  \
-       if (!(condition))                                               \
-               __ret = __wait_event_freezable(wq, condition);          \
-       __ret;                                                          \
+#define wait_event_freezable(wq_head, condition)                               \
+({                                                                             \
+       int __ret = 0;                                                          \
+       might_sleep();                                                          \
+       if (!(condition))                                                       \
+               __ret = __wait_event_freezable(wq_head, condition);             \
+       __ret;                                                                  \
 })
 
-#define __wait_event_timeout(wq, condition, timeout)                   \
-       ___wait_event(wq, ___wait_cond_timeout(condition),              \
-                     TASK_UNINTERRUPTIBLE, 0, timeout,                 \
+#define __wait_event_timeout(wq_head, condition, timeout)                      \
+       ___wait_event(wq_head, ___wait_cond_timeout(condition),                 \
+                     TASK_UNINTERRUPTIBLE, 0, timeout,                         \
                      __ret = schedule_timeout(__ret))
 
 /**
  * wait_event_timeout - sleep until a condition gets true or a timeout elapses
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @timeout: timeout, in jiffies
  *
  * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
  * @condition evaluates to true. The @condition is checked each time
- * the waitqueue @wq is woken up.
+ * the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -375,83 +349,83 @@ do {                                                                      \
  * or the remaining jiffies (at least 1) if the @condition evaluated
  * to %true before the @timeout elapsed.
  */
-#define wait_event_timeout(wq, condition, timeout)                     \
-({                                                                     \
-       long __ret = timeout;                                           \
-       might_sleep();                                                  \
-       if (!___wait_cond_timeout(condition))                           \
-               __ret = __wait_event_timeout(wq, condition, timeout);   \
-       __ret;                                                          \
+#define wait_event_timeout(wq_head, condition, timeout)                                \
+({                                                                             \
+       long __ret = timeout;                                                   \
+       might_sleep();                                                          \
+       if (!___wait_cond_timeout(condition))                                   \
+               __ret = __wait_event_timeout(wq_head, condition, timeout);      \
+       __ret;                                                                  \
 })
 
-#define __wait_event_freezable_timeout(wq, condition, timeout)         \
-       ___wait_event(wq, ___wait_cond_timeout(condition),              \
-                     TASK_INTERRUPTIBLE, 0, timeout,                   \
+#define __wait_event_freezable_timeout(wq_head, condition, timeout)            \
+       ___wait_event(wq_head, ___wait_cond_timeout(condition),                 \
+                     TASK_INTERRUPTIBLE, 0, timeout,                           \
                      __ret = schedule_timeout(__ret); try_to_freeze())
 
 /*
  * like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid
  * increasing load and is freezable.
  */
-#define wait_event_freezable_timeout(wq, condition, timeout)           \
-({                                                                     \
-       long __ret = timeout;                                           \
-       might_sleep();                                                  \
-       if (!___wait_cond_timeout(condition))                           \
-               __ret = __wait_event_freezable_timeout(wq, condition, timeout); \
-       __ret;                                                          \
+#define wait_event_freezable_timeout(wq_head, condition, timeout)              \
+({                                                                             \
+       long __ret = timeout;                                                   \
+       might_sleep();                                                          \
+       if (!___wait_cond_timeout(condition))                                   \
+               __ret = __wait_event_freezable_timeout(wq_head, condition, timeout); \
+       __ret;                                                                  \
 })
 
-#define __wait_event_exclusive_cmd(wq, condition, cmd1, cmd2)          \
-       (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 1, 0,  \
+#define __wait_event_exclusive_cmd(wq_head, condition, cmd1, cmd2)             \
+       (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 1, 0,     \
                            cmd1; schedule(); cmd2)
 /*
  * Just like wait_event_cmd(), except it sets exclusive flag
  */
-#define wait_event_exclusive_cmd(wq, condition, cmd1, cmd2)            \
-do {                                                                   \
-       if (condition)                                                  \
-               break;                                                  \
-       __wait_event_exclusive_cmd(wq, condition, cmd1, cmd2);          \
+#define wait_event_exclusive_cmd(wq_head, condition, cmd1, cmd2)               \
+do {                                                                           \
+       if (condition)                                                          \
+               break;                                                          \
+       __wait_event_exclusive_cmd(wq_head, condition, cmd1, cmd2);             \
 } while (0)
 
-#define __wait_event_cmd(wq, condition, cmd1, cmd2)                    \
-       (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0,  \
+#define __wait_event_cmd(wq_head, condition, cmd1, cmd2)                       \
+       (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0,     \
                            cmd1; schedule(); cmd2)
 
 /**
  * wait_event_cmd - sleep until a condition gets true
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @cmd1: the command will be executed before sleep
  * @cmd2: the command will be executed after sleep
  *
  * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
  * @condition evaluates to true. The @condition is checked each time
- * the waitqueue @wq is woken up.
+ * the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
  */
-#define wait_event_cmd(wq, condition, cmd1, cmd2)                      \
-do {                                                                   \
-       if (condition)                                                  \
-               break;                                                  \
-       __wait_event_cmd(wq, condition, cmd1, cmd2);                    \
+#define wait_event_cmd(wq_head, condition, cmd1, cmd2)                         \
+do {                                                                           \
+       if (condition)                                                          \
+               break;                                                          \
+       __wait_event_cmd(wq_head, condition, cmd1, cmd2);                       \
 } while (0)
 
-#define __wait_event_interruptible(wq, condition)                      \
-       ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0,          \
+#define __wait_event_interruptible(wq_head, condition)                         \
+       ___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0,             \
                      schedule())
 
 /**
  * wait_event_interruptible - sleep until a condition gets true
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  *
  * The process is put to sleep (TASK_INTERRUPTIBLE) until the
  * @condition evaluates to true or a signal is received.
- * The @condition is checked each time the waitqueue @wq is woken up.
+ * The @condition is checked each time the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -459,29 +433,29 @@ do {                                                                      \
  * The function will return -ERESTARTSYS if it was interrupted by a
  * signal and 0 if @condition evaluated to true.
  */
-#define wait_event_interruptible(wq, condition)                                \
-({                                                                     \
-       int __ret = 0;                                                  \
-       might_sleep();                                                  \
-       if (!(condition))                                               \
-               __ret = __wait_event_interruptible(wq, condition);      \
-       __ret;                                                          \
+#define wait_event_interruptible(wq_head, condition)                           \
+({                                                                             \
+       int __ret = 0;                                                          \
+       might_sleep();                                                          \
+       if (!(condition))                                                       \
+               __ret = __wait_event_interruptible(wq_head, condition);         \
+       __ret;                                                                  \
 })
 
-#define __wait_event_interruptible_timeout(wq, condition, timeout)     \
-       ___wait_event(wq, ___wait_cond_timeout(condition),              \
-                     TASK_INTERRUPTIBLE, 0, timeout,                   \
+#define __wait_event_interruptible_timeout(wq_head, condition, timeout)                \
+       ___wait_event(wq_head, ___wait_cond_timeout(condition),                 \
+                     TASK_INTERRUPTIBLE, 0, timeout,                           \
                      __ret = schedule_timeout(__ret))
 
 /**
  * wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @timeout: timeout, in jiffies
  *
  * The process is put to sleep (TASK_INTERRUPTIBLE) until the
  * @condition evaluates to true or a signal is received.
- * The @condition is checked each time the waitqueue @wq is woken up.
+ * The @condition is checked each time the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -493,50 +467,49 @@ do {                                                                      \
  * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was
  * interrupted by a signal.
  */
-#define wait_event_interruptible_timeout(wq, condition, timeout)       \
-({                                                                     \
-       long __ret = timeout;                                           \
-       might_sleep();                                                  \
-       if (!___wait_cond_timeout(condition))                           \
-               __ret = __wait_event_interruptible_timeout(wq,          \
-                                               condition, timeout);    \
-       __ret;                                                          \
+#define wait_event_interruptible_timeout(wq_head, condition, timeout)          \
+({                                                                             \
+       long __ret = timeout;                                                   \
+       might_sleep();                                                          \
+       if (!___wait_cond_timeout(condition))                                   \
+               __ret = __wait_event_interruptible_timeout(wq_head,             \
+                                               condition, timeout);            \
+       __ret;                                                                  \
 })
 
-#define __wait_event_hrtimeout(wq, condition, timeout, state)          \
-({                                                                     \
-       int __ret = 0;                                                  \
-       struct hrtimer_sleeper __t;                                     \
-                                                                       \
-       hrtimer_init_on_stack(&__t.timer, CLOCK_MONOTONIC,              \
-                             HRTIMER_MODE_REL);                        \
-       hrtimer_init_sleeper(&__t, current);                            \
-       if ((timeout) != KTIME_MAX)                             \
-               hrtimer_start_range_ns(&__t.timer, timeout,             \
-                                      current->timer_slack_ns,         \
-                                      HRTIMER_MODE_REL);               \
-                                                                       \
-       __ret = ___wait_event(wq, condition, state, 0, 0,               \
-               if (!__t.task) {                                        \
-                       __ret = -ETIME;                                 \
-                       break;                                          \
-               }                                                       \
-               schedule());                                            \
-                                                                       \
-       hrtimer_cancel(&__t.timer);                                     \
-       destroy_hrtimer_on_stack(&__t.timer);                           \
-       __ret;                                                          \
+#define __wait_event_hrtimeout(wq_head, condition, timeout, state)             \
+({                                                                             \
+       int __ret = 0;                                                          \
+       struct hrtimer_sleeper __t;                                             \
+                                                                               \
+       hrtimer_init_on_stack(&__t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);   \
+       hrtimer_init_sleeper(&__t, current);                                    \
+       if ((timeout) != KTIME_MAX)                                             \
+               hrtimer_start_range_ns(&__t.timer, timeout,                     \
+                                      current->timer_slack_ns,                 \
+                                      HRTIMER_MODE_REL);                       \
+                                                                               \
+       __ret = ___wait_event(wq_head, condition, state, 0, 0,                  \
+               if (!__t.task) {                                                \
+                       __ret = -ETIME;                                         \
+                       break;                                                  \
+               }                                                               \
+               schedule());                                                    \
+                                                                               \
+       hrtimer_cancel(&__t.timer);                                             \
+       destroy_hrtimer_on_stack(&__t.timer);                                   \
+       __ret;                                                                  \
 })
 
 /**
  * wait_event_hrtimeout - sleep until a condition gets true or a timeout elapses
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @timeout: timeout, as a ktime_t
  *
  * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
  * @condition evaluates to true or a signal is received.
- * The @condition is checked each time the waitqueue @wq is woken up.
+ * The @condition is checked each time the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -544,25 +517,25 @@ do {                                                                      \
  * The function returns 0 if @condition became true, or -ETIME if the timeout
  * elapsed.
  */
-#define wait_event_hrtimeout(wq, condition, timeout)                   \
-({                                                                     \
-       int __ret = 0;                                                  \
-       might_sleep();                                                  \
-       if (!(condition))                                               \
-               __ret = __wait_event_hrtimeout(wq, condition, timeout,  \
-                                              TASK_UNINTERRUPTIBLE);   \
-       __ret;                                                          \
+#define wait_event_hrtimeout(wq_head, condition, timeout)                      \
+({                                                                             \
+       int __ret = 0;                                                          \
+       might_sleep();                                                          \
+       if (!(condition))                                                       \
+               __ret = __wait_event_hrtimeout(wq_head, condition, timeout,     \
+                                              TASK_UNINTERRUPTIBLE);           \
+       __ret;                                                                  \
 })
 
 /**
  * wait_event_interruptible_hrtimeout - sleep until a condition gets true or a timeout elapses
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @timeout: timeout, as a ktime_t
  *
  * The process is put to sleep (TASK_INTERRUPTIBLE) until the
  * @condition evaluates to true or a signal is received.
- * The @condition is checked each time the waitqueue @wq is woken up.
+ * The @condition is checked each time the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -570,73 +543,73 @@ do {                                                                      \
  * The function returns 0 if @condition became true, -ERESTARTSYS if it was
  * interrupted by a signal, or -ETIME if the timeout elapsed.
  */
-#define wait_event_interruptible_hrtimeout(wq, condition, timeout)     \
-({                                                                     \
-       long __ret = 0;                                                 \
-       might_sleep();                                                  \
-       if (!(condition))                                               \
-               __ret = __wait_event_hrtimeout(wq, condition, timeout,  \
-                                              TASK_INTERRUPTIBLE);     \
-       __ret;                                                          \
+#define wait_event_interruptible_hrtimeout(wq, condition, timeout)             \
+({                                                                             \
+       long __ret = 0;                                                         \
+       might_sleep();                                                          \
+       if (!(condition))                                                       \
+               __ret = __wait_event_hrtimeout(wq, condition, timeout,          \
+                                              TASK_INTERRUPTIBLE);             \
+       __ret;                                                                  \
 })
 
-#define __wait_event_interruptible_exclusive(wq, condition)            \
-       ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0,          \
+#define __wait_event_interruptible_exclusive(wq, condition)                    \
+       ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0,                  \
                      schedule())
 
-#define wait_event_interruptible_exclusive(wq, condition)              \
-({                                                                     \
-       int __ret = 0;                                                  \
-       might_sleep();                                                  \
-       if (!(condition))                                               \
-               __ret = __wait_event_interruptible_exclusive(wq, condition);\
-       __ret;                                                          \
+#define wait_event_interruptible_exclusive(wq, condition)                      \
+({                                                                             \
+       int __ret = 0;                                                          \
+       might_sleep();                                                          \
+       if (!(condition))                                                       \
+               __ret = __wait_event_interruptible_exclusive(wq, condition);    \
+       __ret;                                                                  \
 })
 
-#define __wait_event_killable_exclusive(wq, condition)                 \
-       ___wait_event(wq, condition, TASK_KILLABLE, 1, 0,               \
+#define __wait_event_killable_exclusive(wq, condition)                         \
+       ___wait_event(wq, condition, TASK_KILLABLE, 1, 0,                       \
                      schedule())
 
-#define wait_event_killable_exclusive(wq, condition)                   \
-({                                                                     \
-       int __ret = 0;                                                  \
-       might_sleep();                                                  \
-       if (!(condition))                                               \
-               __ret = __wait_event_killable_exclusive(wq, condition); \
-       __ret;                                                          \
+#define wait_event_killable_exclusive(wq, condition)                           \
+({                                                                             \
+       int __ret = 0;                                                          \
+       might_sleep();                                                          \
+       if (!(condition))                                                       \
+               __ret = __wait_event_killable_exclusive(wq, condition);         \
+       __ret;                                                                  \
 })
 
 
-#define __wait_event_freezable_exclusive(wq, condition)                        \
-       ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0,          \
+#define __wait_event_freezable_exclusive(wq, condition)                                \
+       ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0,                  \
                        schedule(); try_to_freeze())
 
-#define wait_event_freezable_exclusive(wq, condition)                  \
-({                                                                     \
-       int __ret = 0;                                                  \
-       might_sleep();                                                  \
-       if (!(condition))                                               \
-               __ret = __wait_event_freezable_exclusive(wq, condition);\
-       __ret;                                                          \
+#define wait_event_freezable_exclusive(wq, condition)                          \
+({                                                                             \
+       int __ret = 0;                                                          \
+       might_sleep();                                                          \
+       if (!(condition))                                                       \
+               __ret = __wait_event_freezable_exclusive(wq, condition);        \
+       __ret;                                                                  \
 })
 
-extern int do_wait_intr(wait_queue_head_t *, wait_queue_t *);
-extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_t *);
-
-#define __wait_event_interruptible_locked(wq, condition, exclusive, fn) \
-({                                                                     \
-       int __ret;                                                      \
-       DEFINE_WAIT(__wait);                                            \
-       if (exclusive)                                                  \
-               __wait.flags |= WQ_FLAG_EXCLUSIVE;                      \
-       do {                                                            \
-               __ret = fn(&(wq), &__wait);                             \
-               if (__ret)                                              \
-                       break;                                          \
-       } while (!(condition));                                         \
-       __remove_wait_queue(&(wq), &__wait);                            \
-       __set_current_state(TASK_RUNNING);                              \
-       __ret;                                                          \
+extern int do_wait_intr(wait_queue_head_t *, wait_queue_entry_t *);
+extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_entry_t *);
+
+#define __wait_event_interruptible_locked(wq, condition, exclusive, fn)                \
+({                                                                             \
+       int __ret;                                                              \
+       DEFINE_WAIT(__wait);                                                    \
+       if (exclusive)                                                          \
+               __wait.flags |= WQ_FLAG_EXCLUSIVE;                              \
+       do {                                                                    \
+               __ret = fn(&(wq), &__wait);                                     \
+               if (__ret)                                                      \
+                       break;                                                  \
+       } while (!(condition));                                                 \
+       __remove_wait_queue(&(wq), &__wait);                                    \
+       __set_current_state(TASK_RUNNING);                                      \
+       __ret;                                                                  \
 })
 
 
@@ -663,8 +636,8 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_t *);
  * The function will return -ERESTARTSYS if it was interrupted by a
  * signal and 0 if @condition evaluated to true.
  */
-#define wait_event_interruptible_locked(wq, condition)                 \
-       ((condition)                                                    \
+#define wait_event_interruptible_locked(wq, condition)                         \
+       ((condition)                                                            \
         ? 0 : __wait_event_interruptible_locked(wq, condition, 0, do_wait_intr))
 
 /**
@@ -690,8 +663,8 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_t *);
  * The function will return -ERESTARTSYS if it was interrupted by a
  * signal and 0 if @condition evaluated to true.
  */
-#define wait_event_interruptible_locked_irq(wq, condition)             \
-       ((condition)                                                    \
+#define wait_event_interruptible_locked_irq(wq, condition)                     \
+       ((condition)                                                            \
         ? 0 : __wait_event_interruptible_locked(wq, condition, 0, do_wait_intr_irq))
 
 /**
@@ -721,8 +694,8 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_t *);
  * The function will return -ERESTARTSYS if it was interrupted by a
  * signal and 0 if @condition evaluated to true.
  */
-#define wait_event_interruptible_exclusive_locked(wq, condition)       \
-       ((condition)                                                    \
+#define wait_event_interruptible_exclusive_locked(wq, condition)               \
+       ((condition)                                                            \
         ? 0 : __wait_event_interruptible_locked(wq, condition, 1, do_wait_intr))
 
 /**
@@ -752,12 +725,12 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_t *);
  * The function will return -ERESTARTSYS if it was interrupted by a
  * signal and 0 if @condition evaluated to true.
  */
-#define wait_event_interruptible_exclusive_locked_irq(wq, condition)   \
-       ((condition)                                                    \
+#define wait_event_interruptible_exclusive_locked_irq(wq, condition)           \
+       ((condition)                                                            \
         ? 0 : __wait_event_interruptible_locked(wq, condition, 1, do_wait_intr_irq))
 
 
-#define __wait_event_killable(wq, condition)                           \
+#define __wait_event_killable(wq, condition)                                   \
        ___wait_event(wq, condition, TASK_KILLABLE, 0, 0, schedule())
 
 /**
@@ -775,21 +748,21 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_t *);
  * The function will return -ERESTARTSYS if it was interrupted by a
  * signal and 0 if @condition evaluated to true.
  */
-#define wait_event_killable(wq, condition)                             \
-({                                                                     \
-       int __ret = 0;                                                  \
-       might_sleep();                                                  \
-       if (!(condition))                                               \
-               __ret = __wait_event_killable(wq, condition);           \
-       __ret;                                                          \
+#define wait_event_killable(wq_head, condition)                                        \
+({                                                                             \
+       int __ret = 0;                                                          \
+       might_sleep();                                                          \
+       if (!(condition))                                                       \
+               __ret = __wait_event_killable(wq_head, condition);              \
+       __ret;                                                                  \
 })
 
 
-#define __wait_event_lock_irq(wq, condition, lock, cmd)                        \
-       (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0,  \
-                           spin_unlock_irq(&lock);                     \
-                           cmd;                                        \
-                           schedule();                                 \
+#define __wait_event_lock_irq(wq_head, condition, lock, cmd)                   \
+       (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0,     \
+                           spin_unlock_irq(&lock);                             \
+                           cmd;                                                \
+                           schedule();                                         \
                            spin_lock_irq(&lock))
 
 /**
@@ -797,7 +770,7 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_t *);
  *                          condition is checked under the lock. This
  *                          is expected to be called with the lock
  *                          taken.
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @lock: a locked spinlock_t, which will be released before cmd
  *       and schedule() and reacquired afterwards.
@@ -806,7 +779,7 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_t *);
  *
  * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
  * @condition evaluates to true. The @condition is checked each time
- * the waitqueue @wq is woken up.
+ * the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -815,11 +788,11 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_t *);
  * dropped before invoking the cmd and going to sleep and is reacquired
  * afterwards.
  */
-#define wait_event_lock_irq_cmd(wq, condition, lock, cmd)              \
-do {                                                                   \
-       if (condition)                                                  \
-               break;                                                  \
-       __wait_event_lock_irq(wq, condition, lock, cmd);                \
+#define wait_event_lock_irq_cmd(wq_head, condition, lock, cmd)                 \
+do {                                                                           \
+       if (condition)                                                          \
+               break;                                                          \
+       __wait_event_lock_irq(wq_head, condition, lock, cmd);                   \
 } while (0)
 
 /**
@@ -827,14 +800,14 @@ do {                                                                      \
  *                      condition is checked under the lock. This
  *                      is expected to be called with the lock
  *                      taken.
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @lock: a locked spinlock_t, which will be released before schedule()
  *       and reacquired afterwards.
  *
  * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
  * @condition evaluates to true. The @condition is checked each time
- * the waitqueue @wq is woken up.
+ * the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -842,26 +815,26 @@ do {                                                                      \
  * This is supposed to be called while holding the lock. The lock is
  * dropped before going to sleep and is reacquired afterwards.
  */
-#define wait_event_lock_irq(wq, condition, lock)                       \
-do {                                                                   \
-       if (condition)                                                  \
-               break;                                                  \
-       __wait_event_lock_irq(wq, condition, lock, );                   \
+#define wait_event_lock_irq(wq_head, condition, lock)                          \
+do {                                                                           \
+       if (condition)                                                          \
+               break;                                                          \
+       __wait_event_lock_irq(wq_head, condition, lock, );                      \
 } while (0)
 
 
-#define __wait_event_interruptible_lock_irq(wq, condition, lock, cmd)  \
-       ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0,          \
-                     spin_unlock_irq(&lock);                           \
-                     cmd;                                              \
-                     schedule();                                       \
+#define __wait_event_interruptible_lock_irq(wq_head, condition, lock, cmd)     \
+       ___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0,             \
+                     spin_unlock_irq(&lock);                                   \
+                     cmd;                                                      \
+                     schedule();                                               \
                      spin_lock_irq(&lock))
 
 /**
  * wait_event_interruptible_lock_irq_cmd - sleep until a condition gets true.
  *             The condition is checked under the lock. This is expected to
  *             be called with the lock taken.
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @lock: a locked spinlock_t, which will be released before cmd and
  *       schedule() and reacquired afterwards.
@@ -870,7 +843,7 @@ do {                                                                        \
  *
  * The process is put to sleep (TASK_INTERRUPTIBLE) until the
  * @condition evaluates to true or a signal is received. The @condition is
- * checked each time the waitqueue @wq is woken up.
+ * checked each time the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -882,27 +855,27 @@ do {                                                                      \
  * The macro will return -ERESTARTSYS if it was interrupted by a signal
  * and 0 if @condition evaluated to true.
  */
-#define wait_event_interruptible_lock_irq_cmd(wq, condition, lock, cmd)        \
-({                                                                     \
-       int __ret = 0;                                                  \
-       if (!(condition))                                               \
-               __ret = __wait_event_interruptible_lock_irq(wq,         \
-                                               condition, lock, cmd);  \
-       __ret;                                                          \
+#define wait_event_interruptible_lock_irq_cmd(wq_head, condition, lock, cmd)   \
+({                                                                             \
+       int __ret = 0;                                                          \
+       if (!(condition))                                                       \
+               __ret = __wait_event_interruptible_lock_irq(wq_head,            \
+                                               condition, lock, cmd);          \
+       __ret;                                                                  \
 })
 
 /**
  * wait_event_interruptible_lock_irq - sleep until a condition gets true.
  *             The condition is checked under the lock. This is expected
  *             to be called with the lock taken.
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @lock: a locked spinlock_t, which will be released before schedule()
  *       and reacquired afterwards.
  *
  * The process is put to sleep (TASK_INTERRUPTIBLE) until the
  * @condition evaluates to true or signal is received. The @condition is
- * checked each time the waitqueue @wq is woken up.
+ * checked each time the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -913,28 +886,28 @@ do {                                                                      \
  * The macro will return -ERESTARTSYS if it was interrupted by a signal
  * and 0 if @condition evaluated to true.
  */
-#define wait_event_interruptible_lock_irq(wq, condition, lock)         \
-({                                                                     \
-       int __ret = 0;                                                  \
-       if (!(condition))                                               \
-               __ret = __wait_event_interruptible_lock_irq(wq,         \
-                                               condition, lock,);      \
-       __ret;                                                          \
+#define wait_event_interruptible_lock_irq(wq_head, condition, lock)            \
+({                                                                             \
+       int __ret = 0;                                                          \
+       if (!(condition))                                                       \
+               __ret = __wait_event_interruptible_lock_irq(wq_head,            \
+                                               condition, lock,);              \
+       __ret;                                                                  \
 })
 
-#define __wait_event_interruptible_lock_irq_timeout(wq, condition,     \
-                                                   lock, timeout)      \
-       ___wait_event(wq, ___wait_cond_timeout(condition),              \
-                     TASK_INTERRUPTIBLE, 0, timeout,                   \
-                     spin_unlock_irq(&lock);                           \
-                     __ret = schedule_timeout(__ret);                  \
+#define __wait_event_interruptible_lock_irq_timeout(wq_head, condition,                \
+                                                   lock, timeout)              \
+       ___wait_event(wq_head, ___wait_cond_timeout(condition),                 \
+                     TASK_INTERRUPTIBLE, 0, timeout,                           \
+                     spin_unlock_irq(&lock);                                   \
+                     __ret = schedule_timeout(__ret);                          \
                      spin_lock_irq(&lock));
 
 /**
  * wait_event_interruptible_lock_irq_timeout - sleep until a condition gets
  *             true or a timeout elapses. The condition is checked under
  *             the lock. This is expected to be called with the lock taken.
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @lock: a locked spinlock_t, which will be released before schedule()
  *       and reacquired afterwards.
@@ -942,7 +915,7 @@ do {                                                                        \
  *
  * The process is put to sleep (TASK_INTERRUPTIBLE) until the
  * @condition evaluates to true or signal is received. The @condition is
- * checked each time the waitqueue @wq is woken up.
+ * checked each time the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -954,263 +927,42 @@ do {                                                                     \
  * was interrupted by a signal, and the remaining jiffies otherwise
  * if the condition evaluated to true before the timeout elapsed.
  */
-#define wait_event_interruptible_lock_irq_timeout(wq, condition, lock, \
-                                                 timeout)              \
-({                                                                     \
-       long __ret = timeout;                                           \
-       if (!___wait_cond_timeout(condition))                           \
-               __ret = __wait_event_interruptible_lock_irq_timeout(    \
-                                       wq, condition, lock, timeout);  \
-       __ret;                                                          \
+#define wait_event_interruptible_lock_irq_timeout(wq_head, condition, lock,    \
+                                                 timeout)                      \
+({                                                                             \
+       long __ret = timeout;                                                   \
+       if (!___wait_cond_timeout(condition))                                   \
+               __ret = __wait_event_interruptible_lock_irq_timeout(            \
+                                       wq_head, condition, lock, timeout);     \
+       __ret;                                                                  \
 })
 
 /*
  * Waitqueues which are removed from the waitqueue_head at wakeup time
  */
-void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state);
-void prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state);
-long prepare_to_wait_event(wait_queue_head_t *q, wait_queue_t *wait, int state);
-void finish_wait(wait_queue_head_t *q, wait_queue_t *wait);
-long wait_woken(wait_queue_t *wait, unsigned mode, long timeout);
-int woken_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
-int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
-int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
-
-#define DEFINE_WAIT_FUNC(name, function)                               \
-       wait_queue_t name = {                                           \
-               .private        = current,                              \
-               .func           = function,                             \
-               .task_list      = LIST_HEAD_INIT((name).task_list),     \
+void prepare_to_wait(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state);
+void prepare_to_wait_exclusive(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state);
+long prepare_to_wait_event(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state);
+void finish_wait(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
+long wait_woken(struct wait_queue_entry *wq_entry, unsigned mode, long timeout);
+int woken_wake_function(struct wait_queue_entry *wq_entry, unsigned mode, int sync, void *key);
+int autoremove_wake_function(struct wait_queue_entry *wq_entry, unsigned mode, int sync, void *key);
+
+#define DEFINE_WAIT_FUNC(name, function)                                       \
+       struct wait_queue_entry name = {                                        \
+               .private        = current,                                      \
+               .func           = function,                                     \
+               .entry          = LIST_HEAD_INIT((name).entry),                 \
        }
 
 #define DEFINE_WAIT(name) DEFINE_WAIT_FUNC(name, autoremove_wake_function)
 
-#define DEFINE_WAIT_BIT(name, word, bit)                               \
-       struct wait_bit_queue name = {                                  \
-               .key = __WAIT_BIT_KEY_INITIALIZER(word, bit),           \
-               .wait   = {                                             \
-                       .private        = current,                      \
-                       .func           = wake_bit_function,            \
-                       .task_list      =                               \
-                               LIST_HEAD_INIT((name).wait.task_list),  \
-               },                                                      \
-       }
-
-#define init_wait(wait)                                                        \
-       do {                                                            \
-               (wait)->private = current;                              \
-               (wait)->func = autoremove_wake_function;                \
-               INIT_LIST_HEAD(&(wait)->task_list);                     \
-               (wait)->flags = 0;                                      \
+#define init_wait(wait)                                                                \
+       do {                                                                    \
+               (wait)->private = current;                                      \
+               (wait)->func = autoremove_wake_function;                        \
+               INIT_LIST_HEAD(&(wait)->entry);                                 \
+               (wait)->flags = 0;                                              \
        } while (0)
 
-
-extern int bit_wait(struct wait_bit_key *, int);
-extern int bit_wait_io(struct wait_bit_key *, int);
-extern int bit_wait_timeout(struct wait_bit_key *, int);
-extern int bit_wait_io_timeout(struct wait_bit_key *, int);
-
-/**
- * wait_on_bit - wait for a bit to be cleared
- * @word: the word being waited on, a kernel virtual address
- * @bit: the bit of the word being waited on
- * @mode: the task state to sleep in
- *
- * There is a standard hashed waitqueue table for generic use. This
- * is the part of the hashtable's accessor API that waits on a bit.
- * For instance, if one were to have waiters on a bitflag, one would
- * call wait_on_bit() in threads waiting for the bit to clear.
- * One uses wait_on_bit() where one is waiting for the bit to clear,
- * but has no intention of setting it.
- * Returned value will be zero if the bit was cleared, or non-zero
- * if the process received a signal and the mode permitted wakeup
- * on that signal.
- */
-static inline int
-wait_on_bit(unsigned long *word, int bit, unsigned mode)
-{
-       might_sleep();
-       if (!test_bit(bit, word))
-               return 0;
-       return out_of_line_wait_on_bit(word, bit,
-                                      bit_wait,
-                                      mode);
-}
-
-/**
- * wait_on_bit_io - wait for a bit to be cleared
- * @word: the word being waited on, a kernel virtual address
- * @bit: the bit of the word being waited on
- * @mode: the task state to sleep in
- *
- * Use the standard hashed waitqueue table to wait for a bit
- * to be cleared.  This is similar to wait_on_bit(), but calls
- * io_schedule() instead of schedule() for the actual waiting.
- *
- * Returned value will be zero if the bit was cleared, or non-zero
- * if the process received a signal and the mode permitted wakeup
- * on that signal.
- */
-static inline int
-wait_on_bit_io(unsigned long *word, int bit, unsigned mode)
-{
-       might_sleep();
-       if (!test_bit(bit, word))
-               return 0;
-       return out_of_line_wait_on_bit(word, bit,
-                                      bit_wait_io,
-                                      mode);
-}
-
-/**
- * wait_on_bit_timeout - wait for a bit to be cleared or a timeout elapses
- * @word: the word being waited on, a kernel virtual address
- * @bit: the bit of the word being waited on
- * @mode: the task state to sleep in
- * @timeout: timeout, in jiffies
- *
- * Use the standard hashed waitqueue table to wait for a bit
- * to be cleared. This is similar to wait_on_bit(), except also takes a
- * timeout parameter.
- *
- * Returned value will be zero if the bit was cleared before the
- * @timeout elapsed, or non-zero if the @timeout elapsed or process
- * received a signal and the mode permitted wakeup on that signal.
- */
-static inline int
-wait_on_bit_timeout(unsigned long *word, int bit, unsigned mode,
-                   unsigned long timeout)
-{
-       might_sleep();
-       if (!test_bit(bit, word))
-               return 0;
-       return out_of_line_wait_on_bit_timeout(word, bit,
-                                              bit_wait_timeout,
-                                              mode, timeout);
-}
-
-/**
- * wait_on_bit_action - wait for a bit to be cleared
- * @word: the word being waited on, a kernel virtual address
- * @bit: the bit of the word being waited on
- * @action: the function used to sleep, which may take special actions
- * @mode: the task state to sleep in
- *
- * Use the standard hashed waitqueue table to wait for a bit
- * to be cleared, and allow the waiting action to be specified.
- * This is like wait_on_bit() but allows fine control of how the waiting
- * is done.
- *
- * Returned value will be zero if the bit was cleared, or non-zero
- * if the process received a signal and the mode permitted wakeup
- * on that signal.
- */
-static inline int
-wait_on_bit_action(unsigned long *word, int bit, wait_bit_action_f *action,
-                  unsigned mode)
-{
-       might_sleep();
-       if (!test_bit(bit, word))
-               return 0;
-       return out_of_line_wait_on_bit(word, bit, action, mode);
-}
-
-/**
- * wait_on_bit_lock - wait for a bit to be cleared, when wanting to set it
- * @word: the word being waited on, a kernel virtual address
- * @bit: the bit of the word being waited on
- * @mode: the task state to sleep in
- *
- * There is a standard hashed waitqueue table for generic use. This
- * is the part of the hashtable's accessor API that waits on a bit
- * when one intends to set it, for instance, trying to lock bitflags.
- * For instance, if one were to have waiters trying to set bitflag
- * and waiting for it to clear before setting it, one would call
- * wait_on_bit() in threads waiting to be able to set the bit.
- * One uses wait_on_bit_lock() where one is waiting for the bit to
- * clear with the intention of setting it, and when done, clearing it.
- *
- * Returns zero if the bit was (eventually) found to be clear and was
- * set.  Returns non-zero if a signal was delivered to the process and
- * the @mode allows that signal to wake the process.
- */
-static inline int
-wait_on_bit_lock(unsigned long *word, int bit, unsigned mode)
-{
-       might_sleep();
-       if (!test_and_set_bit(bit, word))
-               return 0;
-       return out_of_line_wait_on_bit_lock(word, bit, bit_wait, mode);
-}
-
-/**
- * wait_on_bit_lock_io - wait for a bit to be cleared, when wanting to set it
- * @word: the word being waited on, a kernel virtual address
- * @bit: the bit of the word being waited on
- * @mode: the task state to sleep in
- *
- * Use the standard hashed waitqueue table to wait for a bit
- * to be cleared and then to atomically set it.  This is similar
- * to wait_on_bit(), but calls io_schedule() instead of schedule()
- * for the actual waiting.
- *
- * Returns zero if the bit was (eventually) found to be clear and was
- * set.  Returns non-zero if a signal was delivered to the process and
- * the @mode allows that signal to wake the process.
- */
-static inline int
-wait_on_bit_lock_io(unsigned long *word, int bit, unsigned mode)
-{
-       might_sleep();
-       if (!test_and_set_bit(bit, word))
-               return 0;
-       return out_of_line_wait_on_bit_lock(word, bit, bit_wait_io, mode);
-}
-
-/**
- * wait_on_bit_lock_action - wait for a bit to be cleared, when wanting to set it
- * @word: the word being waited on, a kernel virtual address
- * @bit: the bit of the word being waited on
- * @action: the function used to sleep, which may take special actions
- * @mode: the task state to sleep in
- *
- * Use the standard hashed waitqueue table to wait for a bit
- * to be cleared and then to set it, and allow the waiting action
- * to be specified.
- * This is like wait_on_bit() but allows fine control of how the waiting
- * is done.
- *
- * Returns zero if the bit was (eventually) found to be clear and was
- * set.  Returns non-zero if a signal was delivered to the process and
- * the @mode allows that signal to wake the process.
- */
-static inline int
-wait_on_bit_lock_action(unsigned long *word, int bit, wait_bit_action_f *action,
-                       unsigned mode)
-{
-       might_sleep();
-       if (!test_and_set_bit(bit, word))
-               return 0;
-       return out_of_line_wait_on_bit_lock(word, bit, action, mode);
-}
-
-/**
- * wait_on_atomic_t - Wait for an atomic_t to become 0
- * @val: The atomic value being waited on, a kernel virtual address
- * @action: the function used to sleep, which may take special actions
- * @mode: the task state to sleep in
- *
- * Wait for an atomic_t to become 0.  We abuse the bit-wait waitqueue table for
- * the purpose of getting a waitqueue, but we set the key to a bit number
- * outside of the target 'word'.
- */
-static inline
-int wait_on_atomic_t(atomic_t *val, int (*action)(atomic_t *), unsigned mode)
-{
-       might_sleep();
-       if (atomic_read(val) == 0)
-               return 0;
-       return out_of_line_wait_on_atomic_t(val, action, mode);
-}
-
 #endif /* _LINUX_WAIT_H */