Skip to content

Commit c32f74a

Browse files
Wolfram Sangtorvalds
authored andcommitted
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>
1 parent 406bf31 commit c32f74a

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎include/linux/completion.h‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*
2020
* See also: complete(), wait_for_completion() (and friends _timeout,
2121
* _interruptible, _interruptible_timeout, and _killable), init_completion(),
22-
* and macros DECLARE_COMPLETION(), DECLARE_COMPLETION_ONSTACK(), and
23-
* INIT_COMPLETION().
22+
* reinit_completion(), and macros DECLARE_COMPLETION(),
23+
* DECLARE_COMPLETION_ONSTACK().
2424
*/
2525
struct completion {
2626
unsigned int done;
@@ -65,7 +65,7 @@ struct completion {
6565

6666
/**
6767
* 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
6969
*
7070
* This inline function will initialize a dynamically created completion
7171
* structure.
@@ -76,6 +76,18 @@ static inline void init_completion(struct completion *x)
7676
init_waitqueue_head(&x->wait);
7777
}
7878

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+
*/
86+
static inline void reinit_completion(struct completion *x)
87+
{
88+
x->done = 0;
89+
}
90+
7991
extern void wait_for_completion(struct completion *);
8092
extern void wait_for_completion_io(struct completion *);
8193
extern int wait_for_completion_interruptible(struct completion *x);

0 commit comments

Comments
 (0)