Skip to content

Commit

Permalink
Remove module * parameter from class_create() in chardev2.c (#228)
Browse files Browse the repository at this point in the history
From v6.4, class_create() does not have module *
Same fix as commit 0addb86 to chardev.c
  • Loading branch information
mechanicalamit committed Sep 17, 2023
1 parent 514f206 commit d0f86a2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/chardev2.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/printk.h>
#include <linux/types.h>
#include <linux/uaccess.h> /* for get_user and put_user */
#include <linux/version.h>

#include <asm/errno.h>

Expand Down Expand Up @@ -205,7 +206,11 @@ static int __init chardev2_init(void)
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);
#endif
device_create(cls, NULL, MKDEV(MAJOR_NUM, 0), NULL, DEVICE_FILE_NAME);

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

0 comments on commit d0f86a2

Please sign in to comment.