Skip to content

Commit 16e1b72

Browse files
authored
Merge pull request #301 from charliechiou/master
Align version check
2 parents 7f4bca9 + 86b9b23 commit 16e1b72

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

examples/devicemodel.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ static int devicemodel_probe(struct platform_device *dev)
2323

2424
return 0;
2525
}
26-
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
27-
static int devicemodel_remove(struct platform_device *dev)
28-
#else
26+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
2927
static void devicemodel_remove(struct platform_device *dev)
28+
#else
29+
static int devicemodel_remove(struct platform_device *dev)
3030
#endif
3131
{
3232
pr_info("devicemodel example removed\n");

examples/static_key.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ static int __init chardev_init(void)
6060

6161
pr_info("I was assigned major number %d\n", major);
6262

63-
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
64-
cls = class_create(THIS_MODULE, DEVICE_NAME);
65-
#else
63+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
6664
cls = class_create(DEVICE_NAME);
65+
#else
66+
cls = class_create(THIS_MODULE, DEVICE_NAME);
6767
#endif
6868

6969
device_create(cls, NULL, MKDEV(major, 0), NULL, DEVICE_NAME);

examples/syscall-steal.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,7 @@
3030

3131
/* The in-kernel calls to the ksys_close() syscall were removed in Linux v5.11+.
3232
*/
33-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 7, 0))
34-
35-
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 4, 0)
36-
#define HAVE_KSYS_CLOSE 1
37-
#include <linux/syscalls.h> /* For ksys_close() */
38-
#else
39-
#include <linux/kallsyms.h> /* For kallsyms_lookup_name */
40-
#endif
41-
42-
#else
33+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0))
4334

4435
#if defined(CONFIG_KPROBES)
4536
#define HAVE_KPROBES 1
@@ -64,7 +55,16 @@ static unsigned long sym = 0;
6455
module_param(sym, ulong, 0644);
6556
#endif /* CONFIG_KPROBES */
6657

67-
#endif /* Version < v5.7 */
58+
#else
59+
60+
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 4, 0)
61+
#define HAVE_KSYS_CLOSE 1
62+
#include <linux/syscalls.h> /* For ksys_close() */
63+
#else
64+
#include <linux/kallsyms.h> /* For kallsyms_lookup_name */
65+
#endif
66+
67+
#endif /* Version >= v5.7 */
6868

6969
/* UID we want to spy on - will be filled from the command line. */
7070
static uid_t uid = -1;

0 commit comments

Comments
 (0)