Skip to content

Commit

Permalink
Use proc_ops structure for kernel version >= 5.6.0
Browse files Browse the repository at this point in the history
Since 5.6.0, proc_create requires a proc_ops* argument
instead of file_operations*.
  • Loading branch information
mateuszmandera committed Mar 31, 2020
1 parent 9dd2270 commit 0b11f33
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bbswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#include <linux/suspend.h>
#include <linux/seq_file.h>
#include <linux/pm_runtime.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
#include <linux/proc_fs.h>
#endif

#define BBSWITCH_VERSION "0.8"

Expand Down Expand Up @@ -375,13 +379,23 @@ static int bbswitch_pm_handler(struct notifier_block *nbp,
return 0;
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
static struct proc_ops bbswitch_fops = {
.proc_open = bbswitch_proc_open,
.proc_read = seq_read,
.proc_write = bbswitch_proc_write,
.proc_lseek = seq_lseek,
.proc_release= single_release
};
#else
static struct file_operations bbswitch_fops = {
.open = bbswitch_proc_open,
.read = seq_read,
.write = bbswitch_proc_write,
.llseek = seq_lseek,
.release= single_release
};
#endif

static struct notifier_block nb = {
.notifier_call = &bbswitch_pm_handler
Expand Down

0 comments on commit 0b11f33

Please sign in to comment.