diff --git a/examples/chardev.c b/examples/chardev.c index 7972304..0737779 100644 --- a/examples/chardev.c +++ b/examples/chardev.c @@ -14,6 +14,7 @@ #include #include #include /* for get_user and put_user */ +#include #include @@ -62,7 +63,11 @@ static int __init chardev_init(void) pr_info("I was assigned major number %d.\n", major); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0) + cls = class_create(DEVICE_NAME); +#else cls = class_create(THIS_MODULE, DEVICE_NAME); +#endif device_create(cls, NULL, MKDEV(major, 0), NULL, DEVICE_NAME); pr_info("Device created on /dev/%s\n", DEVICE_NAME);