Skip to content

Commit 45ac408

Browse files
authored
Merge pull request #189 from linD026/master
Improve the compatibility and fix the missing header
2 parents cdf7b42 + 4ee80a3 commit 45ac408

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

examples/chardev2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/module.h> /* Specifically, a module */
1212
#include <linux/printk.h>
1313
#include <linux/types.h>
14+
#include <linux/uaccess.h> /* for get_user and put_user */
1415

1516
#include <asm/errno.h>
1617

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)