summaryrefslogtreecommitdiff
path: root/patches/0090-bluetooth-compilation.patch
blob: 7ec8d35d6d2fc0a8d9925d1358b3f81b4e47745c (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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
From b72939f55d0615b43720568c47ce34bd372624f8 Mon Sep 17 00:00:00 2001
From: Dominik Sliwa <dominik.sliwa@toradex.com>
Date: Thu, 21 Feb 2019 14:06:40 +0100
Subject: [PATCH] bluetooth: bluetooth compilation

---
 net/bluetooth/a2mp.c         |  4 ++--
 net/bluetooth/af_bluetooth.c | 37 ++++++++++++++++++++++++++++++++++++-
 net/bluetooth/hci_sock.c     |  9 +++++++++
 net/bluetooth/l2cap_core.c   |  9 +++++++--
 net/bluetooth/l2cap_sock.c   | 16 ++++++++++++++++
 net/bluetooth/rfcomm/core.c  |  2 +-
 net/bluetooth/rfcomm/sock.c  | 19 ++++++++++++++++++-
 net/bluetooth/sco.c          | 15 +++++++++++++++
 8 files changed, 104 insertions(+), 7 deletions(-)

diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index 6554607..3e48459 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -244,7 +244,7 @@ static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
 		}
 
 		len -= sizeof(*cl);
-		cl = skb_pull(skb, sizeof(*cl));
+		cl = (void *)skb_pull(skb, sizeof(*cl));
 	}
 
 	/* Fall back to L2CAP init sequence */
@@ -284,7 +284,7 @@ static int a2mp_change_notify(struct amp_mgr *mgr, struct sk_buff *skb,
 	while (skb->len >= sizeof(*cl)) {
 		BT_DBG("Controller id %d type %d status %d", cl->id, cl->type,
 		       cl->status);
-		cl = skb_pull(skb, sizeof(*cl));
+		cl = (void *)skb_pull(skb, sizeof(*cl));
 	}
 
 	/* TODO send A2MP_CHANGE_RSP */
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index deacc52..a8269f8 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -649,7 +649,11 @@ static int bt_seq_show(struct seq_file *seq, void *v)
 		seq_printf(seq,
 			   "%pK %-6d %-6u %-6u %-6u %-6lu %-6lu",
 			   sk,
+#if LINUX_VERSION_IS_GEQ(4,13,0)
 			   refcount_read(&sk->sk_refcnt),
+#else
+			   atomic_read(&sk->sk_refcnt),
+#endif
 			   sk_rmem_alloc_get(sk),
 			   sk_wmem_alloc_get(sk),
 			   from_kuid(seq_user_ns(seq), sock_i_uid(sk)),
@@ -673,14 +677,45 @@ static const struct seq_operations bt_seq_ops = {
 	.show  = bt_seq_show,
 };
 
+#if LINUX_VERSION_IS_LESS(4,18,0)
+struct bt_seq_state {
+	struct bt_sock_list *l;
+};
+static int bt_seq_open(struct inode *inode, struct file *file)
+{
+	struct bt_sock_list *sk_list;
+	struct bt_seq_state *s;
+
+	sk_list = PDE_DATA(inode);
+	s = __seq_open_private(file, &bt_seq_ops,
+			       sizeof(struct bt_seq_state));
+	if (!s)
+		return -ENOMEM;
+
+	s->l = sk_list;
+	return 0;
+}
+
+static const struct file_operations bt_fops = {
+	.open = bt_seq_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = seq_release_private
+};
+#endif
+
 int bt_procfs_init(struct net *net, const char *name,
 		   struct bt_sock_list *sk_list,
 		   int (* seq_show)(struct seq_file *, void *))
 {
 	sk_list->custom_seq_show = seq_show;
-
+#if LINUX_VERSION_IS_GEQ(4,18,0)
 	if (!proc_create_seq_data(name, 0, net->proc_net, &bt_seq_ops, sk_list))
 		return -ENOMEM;
+#else
+	if (!proc_create_data(name, 0, net->proc_net, &bt_fops, sk_list))
+		return -ENOMEM;
+#endif
 	return 0;
 }
 
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 3d3b23d..542fb36 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -1339,8 +1339,13 @@ done:
 	return err;
 }
 
+#if LINUX_VERSION_IS_LESS(4,17,0)
+static int hci_sock_getname(struct socket *sock, struct sockaddr *addr,
+			    int *sockaddr_len, int peer)
+#else
 static int hci_sock_getname(struct socket *sock, struct sockaddr *addr,
 			    int peer)
+#endif
 {
 	struct sockaddr_hci *haddr = (struct sockaddr_hci *)addr;
 	struct sock *sk = sock->sk;
@@ -1363,7 +1368,11 @@ static int hci_sock_getname(struct socket *sock, struct sockaddr *addr,
 	haddr->hci_family = AF_BLUETOOTH;
 	haddr->hci_dev    = hdev->id;
 	haddr->hci_channel= hci_pi(sk)->channel;
+#if LINUX_VERSION_IS_LESS(4,17,0)
+    *sockaddr_len = sizeof(*haddr);
+#else
 	err = sizeof(*haddr);
+#endif
 
 done:
 	release_sock(sk);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 3bbc440..61cb929 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2127,8 +2127,10 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
 	struct sk_buff **frag;
 	int sent = 0;
 
-#if LINUX_VERSION_IS_GEQ(3,19,0)
+#if LINUX_VERSION_IS_GEQ(4,10,0)
 	if (!copy_from_iter_full(skb_put(skb, count), count, &msg->msg_iter))
+#elif LINUX_VERSION_IS_GEQ(3,19,0)
+	if (copy_from_iter(skb_put(skb, count), count, &msg->msg_iter) != count)
 #else
 	if (chan->ops->memcpy_fromiovec(chan, skb_put(skb, count),
 					msg->msg_iov, count))
@@ -2152,9 +2154,12 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
 
 		*frag = tmp;
 
-#if LINUX_VERSION_IS_GEQ(3,19,0)
+#if LINUX_VERSION_IS_GEQ(4,10,0)
 		if (!copy_from_iter_full(skb_put(*frag, count), count,
 				   &msg->msg_iter))
+#elif LINUX_VERSION_IS_GEQ(3,19,0)
+		if (copy_from_iter(skb_put(*frag, count), count,
+				   &msg->msg_iter) != count)
 #else
 		if (chan->ops->memcpy_fromiovec(chan, skb_put(*frag, count),
 						msg->msg_iov, count))
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 406638d..04c3e00 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -301,8 +301,13 @@ done:
 	return err;
 }
 
+#if LINUX_VERSION_IS_LESS(4,12,0)
+static int l2cap_sock_accept(struct socket *sock, struct socket *newsock,
+			     int flags)
+#else
 static int l2cap_sock_accept(struct socket *sock, struct socket *newsock,
 			     int flags, bool kern)
+#endif
 {
 	DEFINE_WAIT_FUNC(wait, woken_wake_function);
 	struct sock *sk = sock->sk, *nsk;
@@ -357,8 +362,14 @@ done:
 	return err;
 }
 
+
+#if LINUX_VERSION_IS_LESS(4,17,0)
+static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr,
+			      int *len, int peer)
+#else
 static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr,
 			      int peer)
+#endif
 {
 	struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr;
 	struct sock *sk = sock->sk;
@@ -386,7 +397,12 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr,
 		la->l2_bdaddr_type = chan->src_type;
 	}
 
+#if LINUX_VERSION_IS_LESS(4,17,0)
+	*len = sizeof(struct sockaddr_l2);
+	return 0;
+#else
 	return sizeof(struct sockaddr_l2);
+#endif
 }
 
 static int l2cap_sock_getsockopt_old(struct socket *sock, int optname,
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 2289d6c..8e7a632 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -872,7 +872,7 @@ static int rfcomm_queue_disc(struct rfcomm_dlc *d)
 	if (!skb)
 		return -ENOMEM;
 
-	cmd = __skb_put(skb, sizeof(*cmd));
+	cmd = (void *)__skb_put(skb, sizeof(*cmd));
 	cmd->addr = d->addr;
 	cmd->ctrl = __ctrl(RFCOMM_DISC, 1);
 	cmd->len  = __len8(0);
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 90e1c3b..604cf98 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -204,8 +204,11 @@ static void rfcomm_sock_kill(struct sock *sk)
 {
 	if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
 		return;
-
+#if LINUX_VERSION_IS_GEQ(4,13,0)
 	BT_DBG("sk %p state %d refcnt %d", sk, sk->sk_state, refcount_read(&sk->sk_refcnt));
+#else
+	BT_DBG("sk %p state %d refcnt %d", sk, sk->sk_state, atomic_read(&sk->sk_refcnt));
+#endif
 
 	/* Kill poor orphan */
 	bt_sock_unlink(&rfcomm_sk_list, sk);
@@ -481,8 +484,12 @@ done:
 	return err;
 }
 
+#if LINUX_VERSION_IS_LESS(4,12,0)
+static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int flags)
+#else
 static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int flags,
 			      bool kern)
+#endif
 {
 	DEFINE_WAIT_FUNC(wait, woken_wake_function);
 	struct sock *sk = sock->sk, *nsk;
@@ -542,7 +549,12 @@ done:
 	return err;
 }
 
+#if LINUX_VERSION_IS_LESS(4,17,0)
+static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr,
+			       int *len, int peer)
+#else
 static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr, int peer)
+#endif
 {
 	struct sockaddr_rc *sa = (struct sockaddr_rc *) addr;
 	struct sock *sk = sock->sk;
@@ -561,7 +573,12 @@ static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr, int p
 	else
 		bacpy(&sa->rc_bdaddr, &rfcomm_pi(sk)->src);
 
+#if LINUX_VERSION_IS_LESS(4,17,0)
+	*len = sizeof(struct sockaddr_rc);
+	return 0;
+#else
 	return sizeof(struct sockaddr_rc);
+#endif
 }
 
 static int rfcomm_sock_sendmsg(struct socket *sock, struct msghdr *msg,
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index c719f08..aafe828 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -625,8 +625,13 @@ done:
 	return err;
 }
 
+#if LINUX_VERSION_IS_LESS(4,12,0)
+static int sco_sock_accept(struct socket *sock, struct socket *newsock,
+			   int flags)
+#else
 static int sco_sock_accept(struct socket *sock, struct socket *newsock,
 			   int flags, bool kern)
+#endif
 {
 	DEFINE_WAIT_FUNC(wait, woken_wake_function);
 	struct sock *sk = sock->sk, *ch;
@@ -680,8 +685,13 @@ done:
 	return err;
 }
 
+#if LINUX_VERSION_IS_LESS(4,17,0)
+static int sco_sock_getname(struct socket *sock, struct sockaddr *addr,
+			    int *len, int peer)
+#else
 static int sco_sock_getname(struct socket *sock, struct sockaddr *addr,
 			    int peer)
+#endif
 {
 	struct sockaddr_sco *sa = (struct sockaddr_sco *) addr;
 	struct sock *sk = sock->sk;
@@ -695,7 +705,12 @@ static int sco_sock_getname(struct socket *sock, struct sockaddr *addr,
 	else
 		bacpy(&sa->sco_bdaddr, &sco_pi(sk)->src);
 
+#if LINUX_VERSION_IS_LESS(4,17,0)
+	*len = sizeof(struct sockaddr_sco);
+	return 0;
+#else
 	return sizeof(struct sockaddr_sco);
+#endif
 }
 
 static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
-- 
2.13.6