Check whether we got woken because our bit cleared or not.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
= container_of(wait, struct wait_bit_queue, wait);
struct kiocb *iocb = container_of(wb, struct kiocb, ki_wq);
- if (wb->key.flags != key->flags || wb->key.bit_nr != key->bit_nr ||
- test_bit(key->bit_nr, key->flags))
+ if (!wait_bit_cleared(wb, key))
return 0;
list_del_init(&wait->task_list);
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);
+static inline int wait_bit_cleared(struct wait_bit_queue *wb,
+ struct wait_bit_key *key)
+{
+ if (wb->key.flags != key->flags || wb->key.bit_nr != key->bit_nr ||
+ test_bit(key->bit_nr, key->flags))
+ return 0;
+
+ return 1;
+}
+
#define DEFINE_WAIT_FUNC(name, function) \
wait_queue_t name = { \
.private = current, \
struct wait_bit_queue *wait_bit
= container_of(wait, struct wait_bit_queue, wait);
- if (wait_bit->key.flags != key->flags ||
- wait_bit->key.bit_nr != key->bit_nr ||
- test_bit(key->bit_nr, key->flags))
+ if (!wait_bit_cleared(wait_bit, key))
return 0;
- else
- return autoremove_wake_function(wait, mode, sync, key);
+
+ return autoremove_wake_function(wait, mode, sync, key);
}
EXPORT_SYMBOL(wake_bit_function);