From e1b44579b0f416a20cfe7b9ba0205e1fb674dba5 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Tue, 16 Apr 2024 06:24:06 +0800 Subject: [PATCH] Ensure Linux v6.5 compatibility --- examples/static_key.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/static_key.c b/examples/static_key.c index 3e56941..b27d4a7 100644 --- a/examples/static_key.c +++ b/examples/static_key.c @@ -61,7 +61,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(THIS_MODULE, DEVICE_NAME); +#else + cls = class_create(DEVICE_NAME); +#endif device_create(cls, NULL, MKDEV(major, 0), NULL, DEVICE_NAME);