gl-mifi-mcu: compatibility with linux >= 5.6
authorIlya Lipnitskiy <[email protected]>
Thu, 28 Jan 2021 06:39:10 +0000 (22:39 -0800)
committerNuno Goncalves <[email protected]>
Thu, 28 Jan 2021 06:53:11 +0000 (07:53 +0100)
Signed-off-by: Ilya Lipnitskiy <[email protected]>
utils/gl-mifi-mcu/src/module.c

index 39a83267d7e1968375752ff4f06b16de43f34948..8f5a5146b25073afb51f18ff939135835c1930ef 100755 (executable)
@@ -5,6 +5,7 @@
 #include <linux/ktime.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/version.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Nuno Goncalves");
@@ -36,13 +37,22 @@ static int proc_open(struct inode *inode, struct  file *file)
   return single_open(file, proc_show, NULL);
 }
 
-static const struct file_operations hello_proc_fops = {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
+static const struct proc_ops hello_proc_ops = {
+  .proc_open = proc_open,
+  .proc_read = seq_read,
+  .proc_lseek = seq_lseek,
+  .proc_release = single_release,
+};
+#else
+static const struct file_operations hello_proc_ops = {
   .owner = THIS_MODULE,
   .open = proc_open,
   .read = seq_read,
   .llseek = seq_lseek,
   .release = single_release,
 };
+#endif
 
 static irq_handler_t handle_rx_start(unsigned int irq, void* device, struct pt_regs* registers)
 {
@@ -158,7 +168,7 @@ static int __init init(void)
 {
   bool success = true;
 
-  proc_create("gl_mifi_mcu", 0, NULL, &hello_proc_fops);
+  proc_create("gl_mifi_mcu", 0, NULL, &hello_proc_ops);
 
   success &= gpio_request(gpio_tx, "soft_uart_tx") == 0;
   success &= gpio_direction_output(gpio_tx, 1) == 0;