Commit c32f74ab authored by Wolfram Sang's avatar Wolfram Sang Committed by Linus Torvalds

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: default avatarWolfram 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 406bf318
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
* *
* See also: complete(), wait_for_completion() (and friends _timeout, * See also: complete(), wait_for_completion() (and friends _timeout,
* _interruptible, _interruptible_timeout, and _killable), init_completion(), * _interruptible, _interruptible_timeout, and _killable), init_completion(),
* and macros DECLARE_COMPLETION(), DECLARE_COMPLETION_ONSTACK(), and * reinit_completion(), and macros DECLARE_COMPLETION(),
* INIT_COMPLETION(). * DECLARE_COMPLETION_ONSTACK().
*/ */
struct completion { struct completion {
unsigned int done; unsigned int done;
...@@ -65,7 +65,7 @@ struct completion { ...@@ -65,7 +65,7 @@ struct completion {
/** /**
* init_completion - Initialize a dynamically allocated completion * init_completion - Initialize a dynamically allocated completion
* @x: completion structure that is to be initialized * @x: pointer to completion structure that is to be initialized
* *
* This inline function will initialize a dynamically created completion * This inline function will initialize a dynamically created completion
* structure. * structure.
...@@ -76,6 +76,18 @@ static inline void init_completion(struct completion *x) ...@@ -76,6 +76,18 @@ static inline void init_completion(struct completion *x)
init_waitqueue_head(&x->wait); init_waitqueue_head(&x->wait);
} }
/**
* reinit_completion - reinitialize a completion structure
* @x: pointer to completion structure that is to be reinitialized
*
* This inline function should be used to reinitialize a completion structure so it can
* be reused. This is especially important after complete_all() is used.
*/
static inline void reinit_completion(struct completion *x)
{
x->done = 0;
}
extern void wait_for_completion(struct completion *); extern void wait_for_completion(struct completion *);
extern void wait_for_completion_io(struct completion *); extern void wait_for_completion_io(struct completion *);
extern int wait_for_completion_interruptible(struct completion *x); extern int wait_for_completion_interruptible(struct completion *x);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment