Skip to content

Commit 1c31bac

Browse files
committed
Fix Linux v6.5 compatibility
1 parent f5893d8 commit 1c31bac

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

examples/ioctl.c

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/module.h>
99
#include <linux/slab.h>
1010
#include <linux/uaccess.h>
11+
#include <linux/version.h>
1112

1213
struct ioctl_arg {
1314
unsigned int val;
@@ -139,7 +140,9 @@ static int test_ioctl_open(struct inode *inode, struct file *filp)
139140
}
140141

141142
static struct file_operations fops = {
143+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
142144
.owner = THIS_MODULE,
145+
#endif
143146
.open = test_ioctl_open,
144147
.release = test_ioctl_close,
145148
.read = test_ioctl_read,

examples/static_key.c

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/types.h>
1212
#include <linux/uaccess.h> /* for get_user and put_user */
1313
#include <linux/jump_label.h> /* for static key macros */
14+
#include <linux/version.h>
1415

1516
#include <asm/errno.h>
1617

@@ -41,7 +42,9 @@ static struct class *cls;
4142
static DEFINE_STATIC_KEY_FALSE(fkey);
4243

4344
static struct file_operations chardev_fops = {
45+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
4446
.owner = THIS_MODULE,
47+
#endif
4548
.open = device_open,
4649
.release = device_release,
4750
.read = device_read,

examples/vinput.c

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/module.h>
88
#include <linux/slab.h>
99
#include <linux/spinlock.h>
10+
#include <linux/version.h>
1011

1112
#include <asm/uaccess.h>
1213

@@ -132,7 +133,9 @@ static ssize_t vinput_write(struct file *file, const char __user *buffer,
132133
}
133134

134135
static const struct file_operations vinput_fops = {
136+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
135137
.owner = THIS_MODULE,
138+
#endif
136139
.open = vinput_open,
137140
.release = vinput_release,
138141
.read = vinput_read,
@@ -240,7 +243,12 @@ static int vinput_register_vdevice(struct vinput *vinput)
240243
return err;
241244
}
242245

246+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
247+
static ssize_t export_store(const struct class *class,
248+
const struct class_attribute *attr,
249+
#else
243250
static ssize_t export_store(struct class *class, struct class_attribute *attr,
251+
#endif
244252
const char *buf, size_t len)
245253
{
246254
int err;
@@ -281,7 +289,12 @@ static ssize_t export_store(struct class *class, struct class_attribute *attr,
281289
/* This macro generates class_attr_export structure and export_store() */
282290
static CLASS_ATTR_WO(export);
283291

292+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
293+
static ssize_t unexport_store(const struct class *class,
294+
const struct class_attribute *attr,
295+
#else
284296
static ssize_t unexport_store(struct class *class, struct class_attribute *attr,
297+
#endif
285298
const char *buf, size_t len)
286299
{
287300
int err;
@@ -322,7 +335,9 @@ ATTRIBUTE_GROUPS(vinput_class);
322335

323336
static struct class vinput_class = {
324337
.name = "vinput",
338+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
325339
.owner = THIS_MODULE,
340+
#endif
326341
.class_groups = vinput_class_groups,
327342
};
328343

0 commit comments

Comments
 (0)