ソースを参照

Fix Linux v6.5 compatibility

Jim Huang 1 年間 前
コミット
1c31bac22c
3 ファイル変更21 行追加0 行削除
  1. 3 0
      examples/ioctl.c
  2. 3 0
      examples/static_key.c
  3. 15 0
      examples/vinput.c

+ 3 - 0
examples/ioctl.c

@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/version.h>
 
 struct ioctl_arg {
     unsigned int val;
@@ -139,7 +140,9 @@ static int test_ioctl_open(struct inode *inode, struct file *filp)
 }
 
 static struct file_operations fops = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
     .owner = THIS_MODULE,
+#endif
     .open = test_ioctl_open,
     .release = test_ioctl_close,
     .read = test_ioctl_read,

+ 3 - 0
examples/static_key.c

@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/uaccess.h> /* for get_user and put_user */
 #include <linux/jump_label.h> /* for static key macros */
+#include <linux/version.h>
 
 #include <asm/errno.h>
 
@@ -41,7 +42,9 @@ static struct class *cls;
 static DEFINE_STATIC_KEY_FALSE(fkey);
 
 static struct file_operations chardev_fops = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
     .owner = THIS_MODULE,
+#endif
     .open = device_open,
     .release = device_release,
     .read = device_read,

+ 15 - 0
examples/vinput.c

@@ -7,6 +7,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/version.h>
 
 #include <asm/uaccess.h>
 
@@ -132,7 +133,9 @@ static ssize_t vinput_write(struct file *file, const char __user *buffer,
 }
 
 static const struct file_operations vinput_fops = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
     .owner = THIS_MODULE,
+#endif
     .open = vinput_open,
     .release = vinput_release,
     .read = vinput_read,
@@ -240,7 +243,12 @@ static int vinput_register_vdevice(struct vinput *vinput)
     return err;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
+static ssize_t export_store(const struct class *class,
+                            const struct class_attribute *attr,
+#else
 static ssize_t export_store(struct class *class, struct class_attribute *attr,
+#endif
                             const char *buf, size_t len)
 {
     int err;
@@ -281,7 +289,12 @@ fail:
 /* This macro generates class_attr_export structure and export_store() */
 static CLASS_ATTR_WO(export);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
+static ssize_t unexport_store(const struct class *class,
+                              const struct class_attribute *attr,
+#else
 static ssize_t unexport_store(struct class *class, struct class_attribute *attr,
+#endif
                               const char *buf, size_t len)
 {
     int err;
@@ -322,7 +335,9 @@ ATTRIBUTE_GROUPS(vinput_class);
 
 static struct class vinput_class = {
     .name = "vinput",
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
     .owner = THIS_MODULE,
+#endif
     .class_groups = vinput_class_groups,
 };