소스 검색

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

From v6.4, class_create() does not have module *
Same fix as commit 0addb868dc55 to chardev.c
Amit Dhingra 1 년 전
부모
커밋
d0f86a29f0
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      examples/chardev2.c

+ 5 - 0
examples/chardev2.c

@@ -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>
 
@@ -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);