From d0f86a29f01b4ec1bd4f7ffeaed896ddc43ff687 Mon Sep 17 00:00:00 2001 From: Amit Dhingra Date: Sun, 17 Sep 2023 12:23:45 +0200 Subject: [PATCH] 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 --- examples/chardev2.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/chardev2.c b/examples/chardev2.c index c77b255..1be9290 100644 --- a/examples/chardev2.c +++ b/examples/chardev2.c @@ -12,6 +12,7 @@ #include #include #include /* for get_user and put_user */ +#include #include @@ -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);