diff --git a/examples/devicemodel.c b/examples/devicemodel.c index 6646c05..90a4851 100644 --- a/examples/devicemodel.c +++ b/examples/devicemodel.c @@ -23,10 +23,10 @@ static int devicemodel_probe(struct platform_device *dev) return 0; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0) -static int devicemodel_remove(struct platform_device *dev) -#else +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) static void devicemodel_remove(struct platform_device *dev) +#else +static int devicemodel_remove(struct platform_device *dev) #endif { pr_info("devicemodel example removed\n"); diff --git a/examples/static_key.c b/examples/static_key.c index 0bd1410..1b5b739 100644 --- a/examples/static_key.c +++ b/examples/static_key.c @@ -60,10 +60,10 @@ 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 +#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); diff --git a/examples/syscall-steal.c b/examples/syscall-steal.c index e0d5bd3..3cfb3ce 100644 --- a/examples/syscall-steal.c +++ b/examples/syscall-steal.c @@ -30,16 +30,7 @@ /* The in-kernel calls to the ksys_close() syscall were removed in Linux v5.11+. */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 7, 0)) - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 4, 0) -#define HAVE_KSYS_CLOSE 1 -#include /* For ksys_close() */ -#else -#include /* For kallsyms_lookup_name */ -#endif - -#else +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)) #if defined(CONFIG_KPROBES) #define HAVE_KPROBES 1 @@ -64,7 +55,16 @@ static unsigned long sym = 0; module_param(sym, ulong, 0644); #endif /* CONFIG_KPROBES */ -#endif /* Version < v5.7 */ +#else + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 4, 0) +#define HAVE_KSYS_CLOSE 1 +#include /* For ksys_close() */ +#else +#include /* For kallsyms_lookup_name */ +#endif + +#endif /* Version >= v5.7 */ /* UID we want to spy on - will be filled from the command line. */ static uid_t uid = -1;