Skip to content

Commit d0f86a2

Browse files
Remove module * parameter from class_create() in chardev2.c (#228)
From v6.4, class_create() does not have module * Same fix as commit 0addb86 to chardev.c
1 parent 514f206 commit d0f86a2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/chardev2.c

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/printk.h>
1313
#include <linux/types.h>
1414
#include <linux/uaccess.h> /* for get_user and put_user */
15+
#include <linux/version.h>
1516

1617
#include <asm/errno.h>
1718

@@ -205,7 +206,11 @@ static int __init chardev2_init(void)
205206
return ret_val;
206207
}
207208

209+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
210+
cls = class_create(DEVICE_FILE_NAME);
211+
#else
208212
cls = class_create(THIS_MODULE, DEVICE_FILE_NAME);
213+
#endif
209214
device_create(cls, NULL, MKDEV(MAJOR_NUM, 0), NULL, DEVICE_FILE_NAME);
210215

211216
pr_info("Device created on /dev/%s\n", DEVICE_FILE_NAME);

0 commit comments

Comments
 (0)