Remove module * parameter from class_create() in chardev2.c (#228)

From v6.4, class_create() does not have module *
Same fix as commit 0addb868dc to chardev.c
This commit is contained in:
Amit Dhingra 2023-09-17 12:23:45 +02:00 committed by GitHub
parent 514f206da0
commit d0f86a29f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,7 @@
#include <linux/printk.h> #include <linux/printk.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/uaccess.h> /* for get_user and put_user */ #include <linux/uaccess.h> /* for get_user and put_user */
#include <linux/version.h>
#include <asm/errno.h> #include <asm/errno.h>
@ -205,7 +206,11 @@ static int __init chardev2_init(void)
return ret_val; return ret_val;
} }
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
cls = class_create(DEVICE_FILE_NAME);
#else
cls = class_create(THIS_MODULE, DEVICE_FILE_NAME); cls = class_create(THIS_MODULE, DEVICE_FILE_NAME);
#endif
device_create(cls, NULL, MKDEV(MAJOR_NUM, 0), NULL, DEVICE_FILE_NAME); device_create(cls, NULL, MKDEV(MAJOR_NUM, 0), NULL, DEVICE_FILE_NAME);
pr_info("Device created on /dev/%s\n", DEVICE_FILE_NAME); pr_info("Device created on /dev/%s\n", DEVICE_FILE_NAME);