* sched/wait: Introduce a wait_on_bit_timeout() helper function
@ 2015-01-30 11:14 Johan Hedberg
2015-01-30 11:14 ` [PATCH] sched/wait: Introduce wait_on_bit_timeout() Johan Hedberg
0 siblings, 1 reply; 3+ messages in thread
From: Johan Hedberg @ 2015-01-30 11:14 UTC (permalink / raw)
To: linux-kernel; +Cc: peterz, mingo, davem, linux-bluetooth
Hi,
We'd need this helper function for the btusb driver for waiting for
certain firmware loading stages which are indicated through a bit-field.
For now we made a local copy in btusb [1] with the intention to switch to
this global version as soon as it makes it upstream. If it's ok we can
also take the patch through the bluetooth-next tree and get it from
there upstream.
Johan
[1] http://marc.info/?l=linux-bluetooth&m=142260834526228&w=2
----------------------------------------------------------------
Johan Hedberg (1):
sched/wait: Introduce wait_on_bit_timeout()
include/linux/wait.h | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH] sched/wait: Introduce wait_on_bit_timeout() 2015-01-30 11:14 sched/wait: Introduce a wait_on_bit_timeout() helper function Johan Hedberg @ 2015-01-30 11:14 ` Johan Hedberg 2015-02-04 14:36 ` [tip:sched/core] " tip-bot for Johan Hedberg 0 siblings, 1 reply; 3+ messages in thread From: Johan Hedberg @ 2015-01-30 11:14 UTC (permalink / raw) To: linux-kernel; +Cc: peterz, mingo, davem, linux-bluetooth From: Johan Hedberg <johan.hedberg@intel.com> Add a new wait_on_bit_timeout() helper, basically the same as wait_on_bit() except that it also takes a timeout parameter. All the building blocks like bit_wait_timeout() and out_of_line_wait_on_bit_timeout() are already in place so the addition is rather simple. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@redhat.com> --- include/linux/wait.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/wait.h b/include/linux/wait.h index 2232ed16635a..920de6df1210 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -991,6 +991,32 @@ wait_on_bit_io(void *word, int bit, unsigned 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(void *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 -- 2.1.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [tip:sched/core] sched/wait: Introduce wait_on_bit_timeout() 2015-01-30 11:14 ` [PATCH] sched/wait: Introduce wait_on_bit_timeout() Johan Hedberg @ 2015-02-04 14:36 ` tip-bot for Johan Hedberg 0 siblings, 0 replies; 3+ messages in thread From: tip-bot for Johan Hedberg @ 2015-02-04 14:36 UTC (permalink / raw) To: linux-tip-commits Cc: peterz, torvalds, hpa, johan.hedberg, linux-kernel, tglx, mingo Commit-ID: 44fc0e5eec00db5fba748803c95920098089c4cc Gitweb: http://git.kernel.org/tip/44fc0e5eec00db5fba748803c95920098089c4cc Author: Johan Hedberg <johan.hedberg@intel.com> AuthorDate: Fri, 30 Jan 2015 13:14:36 +0200 Committer: Ingo Molnar <mingo@kernel.org> CommitDate: Wed, 4 Feb 2015 07:52:32 +0100 sched/wait: Introduce wait_on_bit_timeout() Add a new wait_on_bit_timeout() helper, basically the same as wait_on_bit() except that it also takes a 'timeout' parameter. All the building blocks like bit_wait_timeout() and out_of_line_wait_on_bit_timeout() are already in place so the addition is rather simple. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: davem@davemloft.net Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/1422616476-2917-2-git-send-email-johan.hedberg@gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org> --- include/linux/wait.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/wait.h b/include/linux/wait.h index 37423e0..537d58e 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -990,6 +990,32 @@ wait_on_bit_io(void *word, int bit, unsigned 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(void *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 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-04 14:37 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-01-30 11:14 sched/wait: Introduce a wait_on_bit_timeout() helper function Johan Hedberg 2015-01-30 11:14 ` [PATCH] sched/wait: Introduce wait_on_bit_timeout() Johan Hedberg 2015-02-04 14:36 ` [tip:sched/core] " tip-bot for Johan Hedberg
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.