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
This commit is contained in:
linD026 2023-03-14 07:59:42 +08:00
parent 8a5879a0fa
commit 4ee80a3e16

View File

@ -7,6 +7,7 @@
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/printk.h> #include <linux/printk.h>
#include <linux/version.h>
static struct { static struct {
struct completion crank_comp; struct completion crank_comp;
@ -18,7 +19,11 @@ static int machine_crank_thread(void *arg)
pr_info("Turn the crank\n"); pr_info("Turn the crank\n");
complete_all(&machine.crank_comp); complete_all(&machine.crank_comp);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
kthread_complete_and_exit(&machine.crank_comp, 0);
#else
complete_and_exit(&machine.crank_comp, 0); complete_and_exit(&machine.crank_comp, 0);
#endif
} }
static int machine_flywheel_spinup_thread(void *arg) static int machine_flywheel_spinup_thread(void *arg)
@ -28,7 +33,11 @@ static int machine_flywheel_spinup_thread(void *arg)
pr_info("Flywheel spins up\n"); pr_info("Flywheel spins up\n");
complete_all(&machine.flywheel_comp); complete_all(&machine.flywheel_comp);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
kthread_complete_and_exit(&machine.flywheel_comp, 0);
#else
complete_and_exit(&machine.flywheel_comp, 0); complete_and_exit(&machine.flywheel_comp, 0);
#endif
} }
static int completions_init(void) static int completions_init(void)