From cdef3a8cc6f725d44dc86cd3b6a134df80cc36bf Mon Sep 17 00:00:00 2001 From: Shan Kang Date: Tue, 4 Jun 2024 14:29:53 +0800 Subject: [PATCH] Fix fred test driver build issue Signed-off-by: Shan Kang --- BM/fred/fred_test_driver.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/BM/fred/fred_test_driver.c b/BM/fred/fred_test_driver.c index 73056837..c600fece 100644 --- a/BM/fred/fred_test_driver.c +++ b/BM/fred/fred_test_driver.c @@ -11,6 +11,7 @@ #include #include #include +#include MODULE_AUTHOR("Shan Kang "); MODULE_VERSION("1.0"); @@ -255,8 +256,15 @@ static int __init fred_test_driver_init(void) goto r_class; } /* Creating struct class */ - //dev_class = class_create(THIS_MODULE, "fred_test_class"); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) + // For kernel versions 2.6.26 and later + dev_class = class_create(THIS_MODULE, "fred_test_class"); +#else + // For older kernel versions dev_class = class_create("fred_test_class"); +#endif + if (IS_ERR(dev_class)) { pr_err("Cannot create the struct class\n"); goto r_class;