Skip to content

Commit 7882987

Browse files
authored
Ensure v6.4 compatibility (#1)
In the previous implementation in the function simrupt_init(), we utilize a function call "class_create()" to create a class structure for the kernel module. This function is explicitly called with "class_create(THIS_MODULE, DEV_NAME)", which will cause a compiling error. The reason is the Linux Kernel removes the module pointer from the function "class_create()" in v6.4.0 and later versions. We should support the capability for versions above v6.4.0 as the corresponding changes have made.
1 parent 817aa25 commit 7882987

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

simrupt.c

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/kfifo.h>
88
#include <linux/module.h>
99
#include <linux/slab.h>
10+
#include <linux/version.h>
1011
#include <linux/workqueue.h>
1112

1213
MODULE_LICENSE("Dual MIT/GPL");
@@ -338,7 +339,11 @@ static int __init simrupt_init(void)
338339
}
339340

340341
/* Create a class structure */
342+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
341343
simrupt_class = class_create(THIS_MODULE, DEV_NAME);
344+
#else
345+
simrupt_class = class_create(DEV_NAME);
346+
#endif
342347
if (IS_ERR(simrupt_class)) {
343348
printk(KERN_ERR "error creating simrupt class\n");
344349
ret = PTR_ERR(simrupt_class);

0 commit comments

Comments
 (0)