Skip to content

Commit 0addb86

Browse files
Remove module * parameter from class_create() (#222)
From v6.4, class_create() does not have module * See commit 11ba11 : > driver core: class: remove module * from class_create() > > The module pointer in class_create() never actually did anything, > and it shouldn't have been requred to be set as a parameter even > if it did something. So just remove it and fix up all callers of the > function in the kernel tree at the same time.
1 parent c94b672 commit 0addb86

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/chardev.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/printk.h>
1515
#include <linux/types.h>
1616
#include <linux/uaccess.h> /* for get_user and put_user */
17+
#include <linux/version.h>
1718

1819
#include <asm/errno.h>
1920

@@ -62,7 +63,11 @@ static int __init chardev_init(void)
6263

6364
pr_info("I was assigned major number %d.\n", major);
6465

66+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
67+
cls = class_create(DEVICE_NAME);
68+
#else
6569
cls = class_create(THIS_MODULE, DEVICE_NAME);
70+
#endif
6671
device_create(cls, NULL, MKDEV(major, 0), NULL, DEVICE_NAME);
6772

6873
pr_info("Device created on /dev/%s\n", DEVICE_NAME);

0 commit comments

Comments
 (0)