Skip to content

Commit 4ee80a3

Browse files
committed
completion: Improve the compatibility with v5.17+
Since v5.17-rc1, particularly after the commit cead1855266 ("exit: Rename complete_and_exit to kthread_complete_and_exit"), complete_and_exit() is renamed to kthread_complete_and_exit(). Close #188
1 parent 8a5879a commit 4ee80a3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

examples/completions.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/kthread.h>
88
#include <linux/module.h>
99
#include <linux/printk.h>
10+
#include <linux/version.h>
1011

1112
static struct {
1213
struct completion crank_comp;
@@ -18,7 +19,11 @@ static int machine_crank_thread(void *arg)
1819
pr_info("Turn the crank\n");
1920

2021
complete_all(&machine.crank_comp);
22+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
23+
kthread_complete_and_exit(&machine.crank_comp, 0);
24+
#else
2125
complete_and_exit(&machine.crank_comp, 0);
26+
#endif
2227
}
2328

2429
static int machine_flywheel_spinup_thread(void *arg)
@@ -28,7 +33,11 @@ static int machine_flywheel_spinup_thread(void *arg)
2833
pr_info("Flywheel spins up\n");
2934

3035
complete_all(&machine.flywheel_comp);
36+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
37+
kthread_complete_and_exit(&machine.flywheel_comp, 0);
38+
#else
3139
complete_and_exit(&machine.flywheel_comp, 0);
40+
#endif
3241
}
3342

3443
static int completions_init(void)

0 commit comments

Comments
 (0)