1From e0ed05200e6e4b86e26e092dc1f16fc8fc1e2b67 Mon Sep 17 00:00:00 2001
2From: Christian Stewart <christian@paral.in>
3Date: Tue, 8 Sep 2020 23:08:39 -0700
4Subject: [PATCH] rtw_proc: convert file_operations to proc_ops for 5.6.x
5 compat
6
7Signed-off-by: Christian Stewart <christian@paral.in>
8[Fix < 5.6.x compile - missing semicolon]
9Signed-off-by: Peter Seiderer <ps.report@gmx.net>
10---
11 os_dep/linux/rtw_proc.c | 40 ++++++++++++++++++++++++++++++++++++++--
12 1 file changed, 38 insertions(+), 2 deletions(-)
13
14diff --git a/os_dep/linux/rtw_proc.c b/os_dep/linux/rtw_proc.c
15index 048080a..6295f66 100644
16--- a/os_dep/linux/rtw_proc.c
17+++ b/os_dep/linux/rtw_proc.c
18@@ -65,9 +65,15 @@ inline struct proc_dir_entry *rtw_proc_create_dir(const char *name, struct proc_
19 }
20
21 inline struct proc_dir_entry *rtw_proc_create_entry(const char *name, struct proc_dir_entry *parent,
22-        const struct file_operations *fops, void * data)
23+	#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0))
24+	const struct file_operations *fops,
25+	#else
26+	const struct proc_ops *fops,
27+	#endif
28+	void * data
29+	)
30 {
31-	struct proc_dir_entry *entry;
32+        struct proc_dir_entry *entry;
33
34 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
35 	entry = proc_create_data(name,  S_IFREG|S_IRUGO|S_IWUGO, parent, fops, data);
36@@ -167,6 +173,7 @@ static ssize_t rtw_drv_proc_write(struct file *file, const char __user *buffer,
37 	return -EROFS;
38 }
39
40+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0))
41 static const struct file_operations rtw_drv_proc_fops = {
42 	.owner = THIS_MODULE,
43 	.open = rtw_drv_proc_open,
44@@ -175,6 +182,15 @@ static const struct file_operations rtw_drv_proc_fops = {
45 	.release = single_release,
46 	.write = rtw_drv_proc_write,
47 };
48+#else
49+static const struct proc_ops rtw_drv_proc_fops = {
50+	.proc_open = rtw_drv_proc_open,
51+	.proc_read = seq_read,
52+	.proc_lseek = seq_lseek,
53+	.proc_release = seq_release,
54+	.proc_write = rtw_drv_proc_write,
55+};
56+#endif
57
58 int rtw_drv_proc_init(void)
59 {
60@@ -776,6 +792,7 @@ static ssize_t rtw_adapter_proc_write(struct file *file, const char __user *buff
61 	return -EROFS;
62 }
63
64+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0))
65 static const struct file_operations rtw_adapter_proc_fops = {
66 	.owner = THIS_MODULE,
67 	.open = rtw_adapter_proc_open,
68@@ -784,6 +801,15 @@ static const struct file_operations rtw_adapter_proc_fops = {
69 	.release = single_release,
70 	.write = rtw_adapter_proc_write,
71 };
72+#else
73+static const struct proc_ops rtw_adapter_proc_fops = {
74+	.proc_open = rtw_adapter_proc_open,
75+	.proc_read = seq_read,
76+	.proc_lseek = seq_lseek,
77+	.proc_release = single_release,
78+	.proc_write = rtw_adapter_proc_write,
79+};
80+#endif
81
82 int proc_get_odm_dbg_comp(struct seq_file *m, void *v)
83 {
84@@ -1030,6 +1056,7 @@ static ssize_t rtw_odm_proc_write(struct file *file, const char __user *buffer,
85 	return -EROFS;
86 }
87
88+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0))
89 static const struct file_operations rtw_odm_proc_fops = {
90 	.owner = THIS_MODULE,
91 	.open = rtw_odm_proc_open,
92@@ -1038,6 +1065,15 @@ static const struct file_operations rtw_odm_proc_fops = {
93 	.release = single_release,
94 	.write = rtw_odm_proc_write,
95 };
96+#else
97+static const struct proc_ops rtw_odm_proc_fops = {
98+	.proc_open = rtw_odm_proc_open,
99+	.proc_read = seq_read,
100+	.proc_lseek = seq_lseek,
101+	.proc_release = single_release,
102+	.proc_write = rtw_odm_proc_write,
103+};
104+#endif
105
106 struct proc_dir_entry *rtw_odm_proc_init(struct net_device *dev)
107 {
108--
1092.29.0
110
111