diff options
Diffstat (limited to 'include/linux/wait.h')
| -rw-r--r-- | include/linux/wait.h | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h index b289c96151ee..dc19880c02f5 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h | |||
| @@ -529,13 +529,13 @@ do { \ | |||
| 529 | 529 | ||
| 530 | /** | 530 | /** |
| 531 | * wait_event_interruptible_hrtimeout - sleep until a condition gets true or a timeout elapses | 531 | * wait_event_interruptible_hrtimeout - sleep until a condition gets true or a timeout elapses |
| 532 | * @wq_head: the waitqueue to wait on | 532 | * @wq: the waitqueue to wait on |
| 533 | * @condition: a C expression for the event to wait for | 533 | * @condition: a C expression for the event to wait for |
| 534 | * @timeout: timeout, as a ktime_t | 534 | * @timeout: timeout, as a ktime_t |
| 535 | * | 535 | * |
| 536 | * The process is put to sleep (TASK_INTERRUPTIBLE) until the | 536 | * The process is put to sleep (TASK_INTERRUPTIBLE) until the |
| 537 | * @condition evaluates to true or a signal is received. | 537 | * @condition evaluates to true or a signal is received. |
| 538 | * The @condition is checked each time the waitqueue @wq_head is woken up. | 538 | * The @condition is checked each time the waitqueue @wq is woken up. |
| 539 | * | 539 | * |
| 540 | * wake_up() has to be called after changing any variable that could | 540 | * wake_up() has to be called after changing any variable that could |
| 541 | * change the result of the wait condition. | 541 | * change the result of the wait condition. |
| @@ -735,12 +735,12 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_entry_t *); | |||
| 735 | 735 | ||
| 736 | /** | 736 | /** |
| 737 | * wait_event_killable - sleep until a condition gets true | 737 | * wait_event_killable - sleep until a condition gets true |
| 738 | * @wq: the waitqueue to wait on | 738 | * @wq_head: the waitqueue to wait on |
| 739 | * @condition: a C expression for the event to wait for | 739 | * @condition: a C expression for the event to wait for |
| 740 | * | 740 | * |
| 741 | * The process is put to sleep (TASK_KILLABLE) until the | 741 | * The process is put to sleep (TASK_KILLABLE) until the |
| 742 | * @condition evaluates to true or a signal is received. | 742 | * @condition evaluates to true or a signal is received. |
| 743 | * The @condition is checked each time the waitqueue @wq is woken up. | 743 | * The @condition is checked each time the waitqueue @wq_head is woken up. |
| 744 | * | 744 | * |
| 745 | * wake_up() has to be called after changing any variable that could | 745 | * wake_up() has to be called after changing any variable that could |
| 746 | * change the result of the wait condition. | 746 | * change the result of the wait condition. |
| @@ -757,6 +757,43 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_entry_t *); | |||
| 757 | __ret; \ | 757 | __ret; \ |
| 758 | }) | 758 | }) |
| 759 | 759 | ||
| 760 | #define __wait_event_killable_timeout(wq_head, condition, timeout) \ | ||
| 761 | ___wait_event(wq_head, ___wait_cond_timeout(condition), \ | ||
| 762 | TASK_KILLABLE, 0, timeout, \ | ||
| 763 | __ret = schedule_timeout(__ret)) | ||
| 764 | |||
| 765 | /** | ||
| 766 | * wait_event_killable_timeout - sleep until a condition gets true or a timeout elapses | ||
| 767 | * @wq_head: the waitqueue to wait on | ||
| 768 | * @condition: a C expression for the event to wait for | ||
| 769 | * @timeout: timeout, in jiffies | ||
| 770 | * | ||
| 771 | * The process is put to sleep (TASK_KILLABLE) until the | ||
| 772 | * @condition evaluates to true or a kill signal is received. | ||
| 773 | * The @condition is checked each time the waitqueue @wq_head is woken up. | ||
| 774 | * | ||
| 775 | * wake_up() has to be called after changing any variable that could | ||
| 776 | * change the result of the wait condition. | ||
| 777 | * | ||
| 778 | * Returns: | ||
| 779 | * 0 if the @condition evaluated to %false after the @timeout elapsed, | ||
| 780 | * 1 if the @condition evaluated to %true after the @timeout elapsed, | ||
| 781 | * the remaining jiffies (at least 1) if the @condition evaluated | ||
| 782 | * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was | ||
| 783 | * interrupted by a kill signal. | ||
| 784 | * | ||
| 785 | * Only kill signals interrupt this process. | ||
| 786 | */ | ||
| 787 | #define wait_event_killable_timeout(wq_head, condition, timeout) \ | ||
| 788 | ({ \ | ||
| 789 | long __ret = timeout; \ | ||
| 790 | might_sleep(); \ | ||
| 791 | if (!___wait_cond_timeout(condition)) \ | ||
| 792 | __ret = __wait_event_killable_timeout(wq_head, \ | ||
| 793 | condition, timeout); \ | ||
| 794 | __ret; \ | ||
| 795 | }) | ||
| 796 | |||
| 760 | 797 | ||
| 761 | #define __wait_event_lock_irq(wq_head, condition, lock, cmd) \ | 798 | #define __wait_event_lock_irq(wq_head, condition, lock, cmd) \ |
| 762 | (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0, \ | 799 | (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0, \ |
