1
0

4 Commity 26988ef5de ... 16e1b72851

Autor SHA1 Správa Dátum
  Jim Huang 16e1b72851 Merge pull request #301 from charliechiou/master 1 týždeň pred
  Jim Huang 7f4bca9ad5 Merge pull request #304 from EricccTaiwan/master 1 týždeň pred
  Cheng-Yang Chou 2b22c6bba7 Drop .owner for kernel >= 6.4 2 týždňov pred
  Po-Ying Chiu 86b9b23c47 Align version check 2 týždňov pred
4 zmenil súbory, kde vykonal 21 pridanie a 17 odobranie
  1. 3 3
      examples/devicemodel.c
  2. 4 0
      examples/led.c
  3. 3 3
      examples/static_key.c
  4. 11 11
      examples/syscall-steal.c

+ 3 - 3
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");

+ 4 - 0
examples/led.c

@@ -81,7 +81,9 @@ static ssize_t device_write(struct file *file, const char __user *buffer,
 }
 
 static struct file_operations fops = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
     .owner = THIS_MODULE,
+#endif
     .write = device_write,
     .open = device_open,
     .release = device_release,
@@ -112,7 +114,9 @@ static int __init led_init(void)
             MINOR(led_device.dev_num));
 
     /* Prevents module unloading while operations are in use */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
     led_device.cdev.owner = THIS_MODULE;
+#endif
 
     cdev_init(&led_device.cdev, &fops);
     ret = cdev_add(&led_device.cdev, led_device.dev_num, 1);

+ 3 - 3
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);

+ 11 - 11
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 <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;