aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/completion.h
diff options
context:
space:
mode:
authorWolfram Sang <wsa@the-dreams.de>2013-11-14 17:32:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-14 19:32:21 -0500
commitc32f74ab2872994bc8336ed367313da3139350ca (patch)
tree447daece4f5eac46f8af3a5df7d407dcbc011c34 /include/linux/completion.h
parent406bf31893163cbe5b0b03a281685c7dc95c9380 (diff)
sched: replace INIT_COMPLETION with reinit_completion
For the casual device driver writer, it is hard to remember when to use init_completion (to init a completion structure) or INIT_COMPLETION (to *reinit* a completion structure). Furthermore, while all other completion functions exepct a pointer as a parameter, INIT_COMPLETION does not. To make it easier to remember which function to use and to make code more readable, introduce a new inline function with the proper name and consistent argument type. Update the kernel-doc for init_completion while we are here. Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Acked-by: Linus Walleij <linus.walleij@linaro.org> (personally at LCE13) Cc: Ingo Molnar <mingo@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/completion.h')
-rw-r--r--include/linux/completion.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/include/linux/completion.h b/include/linux/completion.h
index 22c33e35bcb2..124e4b4334c1 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -19,8 +19,8 @@
19 * 19 *
20 * See also: complete(), wait_for_completion() (and friends _timeout, 20 * See also: complete(), wait_for_completion() (and friends _timeout,
21 * _interruptible, _interruptible_timeout, and _killable), init_completion(), 21 * _interruptible, _interruptible_timeout, and _killable), init_completion(),
22 * and macros DECLARE_COMPLETION(), DECLARE_COMPLETION_ONSTACK(), and 22 * reinit_completion(), and macros DECLARE_COMPLETION(),
23 * INIT_COMPLETION(). 23 * DECLARE_COMPLETION_ONSTACK().
24 */ 24 */
25struct completion { 25struct completion {
26 unsigned int done; 26 unsigned int done;
@@ -65,7 +65,7 @@ struct completion {
65 65
66/** 66/**
67 * init_completion - Initialize a dynamically allocated completion 67 * init_completion - Initialize a dynamically allocated completion
68 * @x: completion structure that is to be initialized 68 * @x: pointer to completion structure that is to be initialized
69 * 69 *
70 * This inline function will initialize a dynamically created completion 70 * This inline function will initialize a dynamically created completion
71 * structure. 71 * structure.
@@ -76,6 +76,18 @@ static inline void init_completion(struct completion *x)
76 init_waitqueue_head(&x->wait); 76 init_waitqueue_head(&x->wait);
77} 77}
78 78
79/**
80 * reinit_completion - reinitialize a completion structure
81 * @x: pointer to completion structure that is to be reinitialized
82 *
83 * This inline function should be used to reinitialize a completion structure so it can
84 * be reused. This is especially important after complete_all() is used.
85 */
86static inline void reinit_completion(struct completion *x)
87{
88 x->done = 0;
89}
90
79extern void wait_for_completion(struct completion *); 91extern void wait_for_completion(struct completion *);
80extern void wait_for_completion_io(struct completion *); 92extern void wait_for_completion_io(struct completion *);
81extern int wait_for_completion_interruptible(struct completion *x); 93extern int wait_for_completion_interruptible(struct completion *x);