summaryrefslogtreecommitdiff
path: root/net-wireless/ndiswrapper/files/ndiswrapper-1.61-kernel-4.15.patch
blob: 8e87ece03642e25134c8e6f07fe898683ad5a467 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
From: Seth Forshee <seth.forshee@canonical.com>
Date: Wed, 13 Dec 2017 15:53:31 -0600
Subject: [PATCH] Build fixes for Linux 4.15

Fixes two build issues for 4.15:

 - init_timer() was eliminated in 4.15, and all callers were
   converted to using timer_setup(). The callback prototype has
   also changed to pass a timer_list argument instead of callback
   data, and from_timer() must be used to get to the object in
   which the timer is embedded.

 - usb_get_status() was changed to take an additional argument,
   and usb_get_std_status() was added as a wrapper for callers to
   use as a replacment. Call the wrapper in 4.15 and later.

LP: #1737749
---
 driver/ntoskernel.c | 19 ++++++++++++++++++-
 driver/usb.c        | 10 ++++++++--
 driver/wrapndis.c   | 28 ++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/driver/ntoskernel.c b/driver/ntoskernel.c
index 4fe0dc1..156c688 100644
--- a/driver/ntoskernel.c
+++ b/driver/ntoskernel.c
@@ -77,7 +77,6 @@ u64 wrap_ticks_to_boot;
 #if defined(CONFIG_X86_64)
 static struct timer_list shared_data_timer;
 struct kuser_shared_data kuser_shared_data;
-static void update_user_shared_data_proc(unsigned long data);
 #endif
 
 WIN_SYMBOL_MAP("KeTickCount", &jiffies)
@@ -91,7 +90,11 @@ DEFINE_PER_CPU(struct irql_info, irql_info);
 #endif
 
 #if defined(CONFIG_X86_64)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
 static void update_user_shared_data_proc(unsigned long data)
+#else
+static void update_user_shared_data_proc(struct timer_list *t)
+#endif
 {
 	/* timer is supposed to be scheduled every 10ms, but bigger
 	 * intervals seem to work (tried up to 50ms) */
@@ -407,9 +410,15 @@ static void initialize_object(struct dispatcher_header *dh, enum dh_type type,
 	InitializeListHead(&dh->wait_blocks);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
 static void timer_proc(unsigned long data)
 {
 	struct wrap_timer *wrap_timer = (struct wrap_timer *)data;
+#else
+static void timer_proc(struct timer_list *t)
+{
+	struct wrap_timer *wrap_timer = from_timer(wrap_timer, t, timer);
+#endif
 	struct nt_timer *nt_timer;
 	struct kdpc *kdpc;
 
@@ -452,9 +461,13 @@ void wrap_init_timer(struct nt_timer *nt_timer, enum timer_type type,
 		return;
 	}
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
 	init_timer(&wrap_timer->timer);
 	wrap_timer->timer.data = (unsigned long)wrap_timer;
 	wrap_timer->timer.function = timer_proc;
+#else
+	timer_setup(&wrap_timer->timer, timer_proc, 0);
+#endif
 	wrap_timer->nt_timer = nt_timer;
 #ifdef TIMER_DEBUG
 	wrap_timer->wrap_timer_magic = WRAP_TIMER_MAGIC;
@@ -2559,9 +2572,13 @@ int ntoskernel_init(void)
 #if defined(CONFIG_X86_64)
 	memset(&kuser_shared_data, 0, sizeof(kuser_shared_data));
 	*((ULONG64 *)&kuser_shared_data.system_time) = ticks_1601();
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
 	init_timer(&shared_data_timer);
 	shared_data_timer.function = update_user_shared_data_proc;
 	shared_data_timer.data = 0;
+#else
+	timer_setup(&shared_data_timer, update_user_shared_data_proc, 0);
+#endif
 #endif
 	return 0;
 }
diff --git a/driver/usb.c b/driver/usb.c
index 3e7021a..e55c2c6 100644
--- a/driver/usb.c
+++ b/driver/usb.c
@@ -750,6 +750,12 @@ static USBD_STATUS wrap_set_clear_feature(struct usb_device *udev,
 	USBEXIT(return NT_URB_STATUS(nt_urb));
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
+#define wrap_usb_get_status usb_get_status
+#else
+#define wrap_usb_get_status usb_get_std_status
+#endif
+
 static USBD_STATUS wrap_get_status_request(struct usb_device *udev,
 					   struct irp *irp)
 {
@@ -776,8 +782,8 @@ static USBD_STATUS wrap_get_status_request(struct usb_device *udev,
 		return NT_URB_STATUS(nt_urb);
 	}
 	assert(status_req->transfer_buffer_length == sizeof(u16));
-	ret = usb_get_status(udev, type, status_req->index,
-			     status_req->transfer_buffer);
+	ret = wrap_usb_get_status(udev, type, status_req->index,
+				  status_req->transfer_buffer);
 	if (ret >= 0) {
 		assert(ret <= status_req->transfer_buffer_length);
 		status_req->transfer_buffer_length = ret;
diff --git a/driver/wrapndis.c b/driver/wrapndis.c
index 870e4c2..f653440 100644
--- a/driver/wrapndis.c
+++ b/driver/wrapndis.c
@@ -1093,9 +1093,15 @@ send_assoc_event:
 	EXIT2(return);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
 static void iw_stats_timer_proc(unsigned long data)
 {
 	struct ndis_device *wnd = (struct ndis_device *)data;
+#else
+static void iw_stats_timer_proc(struct timer_list *t)
+{
+	struct ndis_device *wnd = from_timer(wnd, t, iw_stats_timer);
+#endif
 
 	ENTER2("%d", wnd->iw_stats_interval);
 	if (wnd->iw_stats_interval > 0) {
@@ -1111,8 +1117,12 @@ static void add_iw_stats_timer(struct ndis_device *wnd)
 		return;
 	if (wnd->iw_stats_interval < 0)
 		wnd->iw_stats_interval *= -1;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
 	wnd->iw_stats_timer.data = (unsigned long)wnd;
 	wnd->iw_stats_timer.function = iw_stats_timer_proc;
+#else
+	timer_setup(&wnd->iw_stats_timer, iw_stats_timer_proc, 0);
+#endif
 	mod_timer(&wnd->iw_stats_timer, jiffies + wnd->iw_stats_interval);
 }
 
@@ -1124,9 +1134,15 @@ static void del_iw_stats_timer(struct ndis_device *wnd)
 	EXIT2(return);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
 static void hangcheck_proc(unsigned long data)
 {
 	struct ndis_device *wnd = (struct ndis_device *)data;
+#else
+static void hangcheck_proc(struct timer_list *t)
+{
+	struct ndis_device *wnd = from_timer(wnd, t, hangcheck_timer);
+#endif
 
 	ENTER3("%d", wnd->hangcheck_interval);
 	if (wnd->hangcheck_interval > 0) {
@@ -1147,8 +1163,12 @@ void hangcheck_add(struct ndis_device *wnd)
 		wnd->hangcheck_interval = hangcheck_interval * HZ;
 	if (wnd->hangcheck_interval < 0)
 		wnd->hangcheck_interval *= -1;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
 	wnd->hangcheck_timer.data = (unsigned long)wnd;
 	wnd->hangcheck_timer.function = hangcheck_proc;
+#else
+	timer_setup(&wnd->hangcheck_timer, hangcheck_proc, 0);
+#endif
 	mod_timer(&wnd->hangcheck_timer, jiffies + wnd->hangcheck_interval);
 	EXIT2(return);
 }
@@ -2138,9 +2158,17 @@ static NTSTATUS ndis_add_device(struct driver_object *drv_obj,
 	wnd->dma_map_count = 0;
 	wnd->dma_map_addr = NULL;
 	wnd->nick[0] = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
 	init_timer(&wnd->hangcheck_timer);
+#else
+	timer_setup(&wnd->hangcheck_timer, NULL, 0);
+#endif
 	wnd->scan_timestamp = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
 	init_timer(&wnd->iw_stats_timer);
+#else
+	timer_setup(&wnd->iw_stats_timer, NULL, 0);
+#endif
 	wnd->iw_stats_interval = 10 * HZ;
 	wnd->ndis_pending_work = 0;
 	memset(&wnd->essid, 0, sizeof(wnd->essid));