mirror of
https://github.com/sysprog21/lkmpg.git
synced 2025-04-22 20:53:23 +08:00
Align version check
The condition ">=" is used to align all version checks, improving code consistency and readability.
This commit is contained in:
parent
9ca77904b8
commit
86b9b23c47
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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 <linux/syscalls.h> /* For ksys_close() */
|
||||
#else
|
||||
#include <linux/kallsyms.h> /* 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 <linux/syscalls.h> /* For ksys_close() */
|
||||
#else
|
||||
#include <linux/kallsyms.h> /* 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user