Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 91558 | Differences between
and this patch

Collapse All | Expand All

(-)linux-2.6.23-gentoo-r9/include/net/bluetooth/hci_core.h (-3 / +5 lines)
Lines 25-30 Link Here
25
#ifndef __HCI_CORE_H
25
#ifndef __HCI_CORE_H
26
#define __HCI_CORE_H
26
#define __HCI_CORE_H
27
27
28
#include <linux/hrtimer.h>
29
28
#include <net/bluetooth/hci.h>
30
#include <net/bluetooth/hci.h>
29
31
30
/* HCI upper protocols */
32
/* HCI upper protocols */
Lines 90-96 struct hci_dev { Link Here
90
92
91
	atomic_t	cmd_cnt;
93
	atomic_t	cmd_cnt;
92
	unsigned int	acl_cnt;
94
	unsigned int	acl_cnt;
93
	unsigned int	sco_cnt;
95
	atomic_t	sco_cnt;
94
96
95
	unsigned int	acl_mtu;
97
	unsigned int	acl_mtu;
96
	unsigned int	sco_mtu;
98
	unsigned int	sco_mtu;
Lines 147-153 struct hci_conn { Link Here
147
	struct list_head list;
149
	struct list_head list;
148
150
149
	atomic_t	 refcnt;
151
	atomic_t	 refcnt;
150
	spinlock_t	 lock;
151
152
152
	bdaddr_t	 dst;
153
	bdaddr_t	 dst;
153
	__u16		 handle;
154
	__u16		 handle;
Lines 164-173 struct hci_conn { Link Here
164
	__u8             power_save;
165
	__u8             power_save;
165
	unsigned long	 pend;
166
	unsigned long	 pend;
166
167
167
	unsigned int	 sent;
168
	atomic_t	 sent;
168
169
169
	struct sk_buff_head data_q;
170
	struct sk_buff_head data_q;
170
171
172
	struct hrtimer tx_timer;
171
	struct timer_list disc_timer;
173
	struct timer_list disc_timer;
172
	struct timer_list idle_timer;
174
	struct timer_list idle_timer;
173
175
(-)linux-2.6.23-gentoo-r9/include/net/bluetooth/sco.h (-5 lines)
Lines 26-37 Link Here
26
#define __SCO_H
26
#define __SCO_H
27
27
28
/* SCO defaults */
28
/* SCO defaults */
29
#define SCO_DEFAULT_MTU		500
30
#define SCO_DEFAULT_FLUSH_TO	0xFFFF
31
32
#define SCO_CONN_TIMEOUT	(HZ * 40)
29
#define SCO_CONN_TIMEOUT	(HZ * 40)
33
#define SCO_DISCONN_TIMEOUT	(HZ * 2)
34
#define SCO_CONN_IDLE_TIMEOUT	(HZ * 60)
35
30
36
/* SCO socket address */
31
/* SCO socket address */
37
struct sockaddr_sco {
32
struct sockaddr_sco {
(-)linux-2.6.23-gentoo-r9/net/bluetooth/hci_conn.c (-1 / +29 lines)
Lines 165-170 static void hci_conn_idle(unsigned long Link Here
165
	hci_conn_enter_sniff_mode(conn);
165
	hci_conn_enter_sniff_mode(conn);
166
}
166
}
167
167
168
static  enum hrtimer_restart hci_sco_tx_timer(struct hrtimer *timer)
169
{
170
	struct hci_conn *conn = container_of(timer, struct hci_conn, tx_timer);
171
#ifdef CONFIG_BT_HCI_CORE_DEBUG
172
	ktime_t now = timer->base->get_time();
173
174
	BT_DBG("%s, conn %p, time %5lu.%06lu", conn->hdev->name, conn,
175
		(unsigned long) now.tv64, 
176
		do_div(now.tv64, NSEC_PER_SEC) / 1000);
177
#endif
178
179
	if (atomic_read(&conn->sent) > 0) {
180
		atomic_dec(&conn->sent);
181
		atomic_inc(&conn->hdev->sco_cnt);
182
		hci_sched_tx(conn->hdev);
183
	}
184
	return HRTIMER_NORESTART;
185
}
186
 
187
168
struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
188
struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
169
{
189
{
170
	struct hci_conn *conn;
190
	struct hci_conn *conn;
Lines 185-190 struct hci_conn *hci_conn_add(struct hci Link Here
185
205
186
	skb_queue_head_init(&conn->data_q);
206
	skb_queue_head_init(&conn->data_q);
187
207
208
	hrtimer_init(&conn->tx_timer, CLOCK_MONOTONIC, HRTIMER_NORESTART);
209
210
	if(type == SCO_LINK)
211
		conn->tx_timer.function = hci_sco_tx_timer;
212
188
	init_timer(&conn->disc_timer);
213
	init_timer(&conn->disc_timer);
189
	conn->disc_timer.function = hci_conn_timeout;
214
	conn->disc_timer.function = hci_conn_timeout;
190
	conn->disc_timer.data = (unsigned long) conn;
215
	conn->disc_timer.data = (unsigned long) conn;
Lines 194-199 struct hci_conn *hci_conn_add(struct hci Link Here
194
	conn->idle_timer.data = (unsigned long) conn;
219
	conn->idle_timer.data = (unsigned long) conn;
195
220
196
	atomic_set(&conn->refcnt, 0);
221
	atomic_set(&conn->refcnt, 0);
222
	atomic_set(&conn->sent, 0);
197
223
198
	hci_dev_hold(hdev);
224
	hci_dev_hold(hdev);
199
225
Lines 220-232 int hci_conn_del(struct hci_conn *conn) Link Here
220
246
221
	del_timer(&conn->disc_timer);
247
	del_timer(&conn->disc_timer);
222
248
249
	hrtimer_cancel(&conn->tx_timer);
250
223
	if (conn->type == ACL_LINK) {
251
	if (conn->type == ACL_LINK) {
224
		struct hci_conn *sco = conn->link;
252
		struct hci_conn *sco = conn->link;
225
		if (sco)
253
		if (sco)
226
			sco->link = NULL;
254
			sco->link = NULL;
227
255
228
		/* Unacked frames */
256
		/* Unacked frames */
229
		hdev->acl_cnt += conn->sent;
257
		hdev->acl_cnt += atomic_read(&conn->sent);
230
	} else {
258
	} else {
231
		struct hci_conn *acl = conn->link;
259
		struct hci_conn *acl = conn->link;
232
		if (acl) {
260
		if (acl) {
(-)linux-2.6.23-gentoo-r9/net/bluetooth/hci_core.c (-30 / +74 lines)
Lines 618-624 int hci_dev_reset(__u16 dev) Link Here
618
		hdev->flush(hdev);
618
		hdev->flush(hdev);
619
619
620
	atomic_set(&hdev->cmd_cnt, 1);
620
	atomic_set(&hdev->cmd_cnt, 1);
621
	hdev->acl_cnt = 0; hdev->sco_cnt = 0;
621
	atomic_set(&hdev->sco_cnt, 0);
622
	hdev->acl_cnt = 0;
622
623
623
	if (!test_bit(HCI_RAW, &hdev->flags))
624
	if (!test_bit(HCI_RAW, &hdev->flags))
624
		ret = __hci_request(hdev, hci_reset_req, 0,
625
		ret = __hci_request(hdev, hci_reset_req, 0,
Lines 1224-1229 int hci_send_sco(struct hci_conn *conn, Link Here
1224
{
1225
{
1225
	struct hci_dev *hdev = conn->hdev;
1226
	struct hci_dev *hdev = conn->hdev;
1226
	struct hci_sco_hdr hdr;
1227
	struct hci_sco_hdr hdr;
1228
	ktime_t now;
1227
1229
1228
	BT_DBG("%s len %d", hdev->name, skb->len);
1230
	BT_DBG("%s len %d", hdev->name, skb->len);
1229
1231
Lines 1232-1237 int hci_send_sco(struct hci_conn *conn, Link Here
1232
		return -EINVAL;
1234
		return -EINVAL;
1233
	}
1235
	}
1234
1236
1237
	now = conn->tx_timer.base->get_time();
1238
1239
	/* force a clean start for 100 ms or later underrun */
1240
	if (conn->tx_timer.expires.tv64 + NSEC_PER_SEC / 10 <= now.tv64) {
1241
		conn->tx_timer.expires = now;
1242
	}
1243
1235
	hdr.handle = cpu_to_le16(conn->handle);
1244
	hdr.handle = cpu_to_le16(conn->handle);
1236
	hdr.dlen   = skb->len;
1245
	hdr.dlen   = skb->len;
1237
1246
Lines 1249-1260 EXPORT_SYMBOL(hci_send_sco); Link Here
1249
1258
1250
/* ---- HCI TX task (outgoing data) ---- */
1259
/* ---- HCI TX task (outgoing data) ---- */
1251
1260
1252
/* HCI Connection scheduler */
1261
/* HCI ACL Connection scheduler */
1253
static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int *quote)
1262
static inline struct hci_conn *hci_low_sent_acl(struct hci_dev *hdev, int *quote)
1254
{
1263
{
1255
	struct hci_conn_hash *h = &hdev->conn_hash;
1264
	struct hci_conn_hash *h = &hdev->conn_hash;
1256
	struct hci_conn *conn = NULL;
1265
	struct hci_conn *conn = NULL;
1257
	int num = 0, min = ~0;
1266
	unsigned int num = 0, min = ~0;
1258
	struct list_head *p;
1267
	struct list_head *p;
1259
1268
1260
	/* We don't have to lock device here. Connections are always
1269
	/* We don't have to lock device here. Connections are always
Lines 1263-1282 static inline struct hci_conn *hci_low_s Link Here
1263
		struct hci_conn *c;
1272
		struct hci_conn *c;
1264
		c = list_entry(p, struct hci_conn, list);
1273
		c = list_entry(p, struct hci_conn, list);
1265
1274
1266
		if (c->type != type || c->state != BT_CONNECTED
1275
		BT_DBG("c->type %d c->state %d len(c->data_q) %d min %d c->sent %d", 
1276
			c->type, c->state, skb_queue_len(&c->data_q), min, atomic_read(&c->sent));
1277
1278
		if (c->type != ACL_LINK || c->state != BT_CONNECTED
1267
				|| skb_queue_empty(&c->data_q))
1279
				|| skb_queue_empty(&c->data_q))
1268
			continue;
1280
			continue;
1269
		num++;
1281
		num++;
1270
1282
1271
		if (c->sent < min) {
1283
		if (atomic_read(&c->sent) < min) {
1272
			min  = c->sent;
1284
			min  = atomic_read(&c->sent);
1273
			conn = c;
1285
			conn = c;
1274
		}
1286
		}
1275
	}
1287
	}
1276
1288
1277
	if (conn) {
1289
	if (conn) {
1278
		int cnt = (type == ACL_LINK ? hdev->acl_cnt : hdev->sco_cnt);
1290
		int q = hdev->acl_cnt / num;
1279
		int q = cnt / num;
1280
		*quote = q ? q : 1;
1291
		*quote = q ? q : 1;
1281
	} else
1292
	} else
1282
		*quote = 0;
1293
		*quote = 0;
Lines 1296-1302 static inline void hci_acl_tx_to(struct Link Here
1296
	/* Kill stalled connections */
1307
	/* Kill stalled connections */
1297
	list_for_each(p, &h->list) {
1308
	list_for_each(p, &h->list) {
1298
		c = list_entry(p, struct hci_conn, list);
1309
		c = list_entry(p, struct hci_conn, list);
1299
		if (c->type == ACL_LINK && c->sent) {
1310
		if (c->type == ACL_LINK && atomic_read(&c->sent)) {
1300
			BT_ERR("%s killing stalled ACL connection %s",
1311
			BT_ERR("%s killing stalled ACL connection %s",
1301
				hdev->name, batostr(&c->dst));
1312
				hdev->name, batostr(&c->dst));
1302
			hci_acl_disconn(c, 0x13);
1313
			hci_acl_disconn(c, 0x13);
Lines 1319-1325 static inline void hci_sched_acl(struct Link Here
1319
			hci_acl_tx_to(hdev);
1330
			hci_acl_tx_to(hdev);
1320
	}
1331
	}
1321
1332
1322
	while (hdev->acl_cnt && (conn = hci_low_sent(hdev, ACL_LINK, &quote))) {
1333
	while (hdev->acl_cnt && (conn = hci_low_sent_acl(hdev, &quote))) {
1323
		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
1334
		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
1324
			BT_DBG("skb %p len %d", skb, skb->len);
1335
			BT_DBG("skb %p len %d", skb, skb->len);
1325
1336
Lines 1329-1356 static inline void hci_sched_acl(struct Link Here
1329
			hdev->acl_last_tx = jiffies;
1340
			hdev->acl_last_tx = jiffies;
1330
1341
1331
			hdev->acl_cnt--;
1342
			hdev->acl_cnt--;
1332
			conn->sent++;
1343
			atomic_inc(&conn->sent);
1333
		}
1344
		}
1334
	}
1345
	}
1335
}
1346
}
1336
1347
1337
/* Schedule SCO */
1348
/* HCI SCO Connection scheduler */
1349
1338
static inline void hci_sched_sco(struct hci_dev *hdev)
1350
static inline void hci_sched_sco(struct hci_dev *hdev)
1339
{
1351
{
1340
	struct hci_conn *conn;
1352
	struct hci_conn_hash *h = &hdev->conn_hash;
1341
	struct sk_buff *skb;
1353
  	struct sk_buff *skb;
1342
	int quote;
1354
	struct list_head *p;
1343
1355
	struct hci_conn *c;
1344
	BT_DBG("%s", hdev->name);
1356
	ktime_t now, pkt_time;
1345
1357
	
1346
	while (hdev->sco_cnt && (conn = hci_low_sent(hdev, SCO_LINK, &quote))) {
1358
  	BT_DBG("%s", hdev->name);
1347
		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
1359
  
1348
			BT_DBG("skb %p len %d", skb, skb->len);
1360
	/* We don't have to lock device here. Connections are always 
1349
			hci_send_frame(skb);
1361
	   added and removed with TX task disabled. */
1350
1362
	list_for_each(p, &h->list) {
1351
			conn->sent++;
1363
		c = list_entry(p, struct hci_conn, list);
1352
			if (conn->sent == ~0)
1364
  
1353
				conn->sent = 0;
1365
		/* SCO scheduling algorithm makes sure there is never more than
1366
		   1 outstanding packet for each connection */
1367
  
1368
		if (c->type == ACL_LINK)
1369
			continue;
1370
  
1371
		if (atomic_read(&c->sent) >= 1)
1372
			continue;
1373
  
1374
		if (c->state != BT_CONNECTED)
1375
			continue;
1376
  
1377
		if (atomic_read(&hdev->sco_cnt) <= 0)
1378
			continue;
1379
  
1380
		if ((skb = skb_dequeue(&c->data_q)) == NULL)
1381
			continue;
1382
  
1383
		hci_send_frame(skb);
1384
 
1385
		atomic_inc(&c->sent);			
1386
		atomic_dec(&hdev->sco_cnt);
1387
					
1388
		pkt_time = ktime_set(0, NSEC_PER_SEC / 16000 * (skb->len - HCI_SCO_HDR_SIZE));
1389
		now = c->tx_timer.base->get_time();
1390
1391
		c->tx_timer.expires.tv64 += pkt_time.tv64;
1392
		if (c->tx_timer.expires.tv64 > now.tv64) {
1393
			hrtimer_restart(&c->tx_timer);
1394
		} else {
1395
			/* Timer is to expire in the past - force timer expiration.
1396
			   this can happen if timer base precision is less than pkt_time */
1397
			c->tx_timer.function(&c->tx_timer);
1354
		}
1398
		}
1355
	}
1399
	}
1356
}
1400
}
Lines 1362-1375 static void hci_tx_task(unsigned long ar Link Here
1362
1406
1363
	read_lock(&hci_task_lock);
1407
	read_lock(&hci_task_lock);
1364
1408
1365
	BT_DBG("%s acl %d sco %d", hdev->name, hdev->acl_cnt, hdev->sco_cnt);
1409
	BT_DBG("%s acl %d sco %d", hdev->name, hdev->acl_cnt, atomic_read(&hdev->sco_cnt));
1366
1410
1367
	/* Schedule queues and send stuff to HCI driver */
1411
	/* Schedule queues and send stuff to HCI driver */
1368
1412
1369
	hci_sched_acl(hdev);
1370
1371
	hci_sched_sco(hdev);
1413
	hci_sched_sco(hdev);
1372
1414
1415
	hci_sched_acl(hdev);
1416
1373
	/* Send next queued raw (unknown type) packet */
1417
	/* Send next queued raw (unknown type) packet */
1374
	while ((skb = skb_dequeue(&hdev->raw_q)))
1418
	while ((skb = skb_dequeue(&hdev->raw_q)))
1375
		hci_send_frame(skb);
1419
		hci_send_frame(skb);
(-)linux-2.6.23-gentoo-r9/net/bluetooth/hci_event.c (-5 / +2 lines)
Lines 394-400 static void hci_cc_info_param(struct hci Link Here
394
		}
394
		}
395
395
396
		hdev->acl_cnt = hdev->acl_pkts;
396
		hdev->acl_cnt = hdev->acl_pkts;
397
		hdev->sco_cnt = hdev->sco_pkts;
397
		atomic_set(&hdev->sco_cnt, hdev->sco_pkts);
398
398
399
		BT_DBG("%s mtu: acl %d, sco %d max_pkt: acl %d, sco %d", hdev->name,
399
		BT_DBG("%s mtu: acl %d, sco %d max_pkt: acl %d, sco %d", hdev->name,
400
			hdev->acl_mtu, hdev->sco_mtu, hdev->acl_pkts, hdev->sco_pkts);
400
			hdev->acl_mtu, hdev->sco_mtu, hdev->acl_pkts, hdev->sco_pkts);
Lines 892-905 static inline void hci_num_comp_pkts_evt Link Here
892
892
893
		conn = hci_conn_hash_lookup_handle(hdev, handle);
893
		conn = hci_conn_hash_lookup_handle(hdev, handle);
894
		if (conn) {
894
		if (conn) {
895
			conn->sent -= count;
895
			atomic_sub(count, &conn->sent);
896
896
897
			if (conn->type == ACL_LINK) {
897
			if (conn->type == ACL_LINK) {
898
				if ((hdev->acl_cnt += count) > hdev->acl_pkts)
898
				if ((hdev->acl_cnt += count) > hdev->acl_pkts)
899
					hdev->acl_cnt = hdev->acl_pkts;
899
					hdev->acl_cnt = hdev->acl_pkts;
900
			} else {
901
				if ((hdev->sco_cnt += count) > hdev->sco_pkts)
902
					hdev->sco_cnt = hdev->sco_pkts;
903
			}
900
			}
904
		}
901
		}
905
	}
902
	}
(-)linux-2.6.23-gentoo-r9/net/bluetooth/sco.c (-16 / +120 lines)
Lines 53-59 Link Here
53
#define BT_DBG(D...)
53
#define BT_DBG(D...)
54
#endif
54
#endif
55
55
56
#define VERSION "0.5"
56
#define VERSION "0.6"
57
58
#define MAX_SCO_TXBUFS 200
59
#define MAX_SCO_RXBUFS 200
60
61
#define DEFAULT_SCO_TXBUFS 5
62
#define DEFAULT_SCO_RXBUFS 5
57
63
58
static const struct proto_ops sco_sock_ops;
64
static const struct proto_ops sco_sock_ops;
59
65
Lines 69-74 static int sco_conn_del(struct hci_conn Link Here
69
static void sco_sock_close(struct sock *sk);
75
static void sco_sock_close(struct sock *sk);
70
static void sco_sock_kill(struct sock *sk);
76
static void sco_sock_kill(struct sock *sk);
71
77
78
/* 
79
 * Write buffer destructor automatically called from kfree_skb. 
80
 */
81
void sco_sock_wfree(struct sk_buff *skb)
82
{
83
	struct sock *sk = skb->sk;
84
85
	atomic_dec(&sk->sk_wmem_alloc);
86
	sk->sk_write_space(sk);
87
	sock_put(sk);
88
}
89
90
static void sco_sock_write_space(struct sock *sk)
91
{
92
	read_lock(&sk->sk_callback_lock);
93
94
	if (atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) {
95
		if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
96
			wake_up_interruptible(sk->sk_sleep);
97
98
		if (sock_writeable(sk))
99
			sk_wake_async(sk, 2, POLL_OUT);
100
	}
101
102
	read_unlock(&sk->sk_callback_lock);
103
}
104
72
/* ---- SCO timers ---- */
105
/* ---- SCO timers ---- */
73
static void sco_sock_timeout(unsigned long arg)
106
static void sco_sock_timeout(unsigned long arg)
74
{
107
{
Lines 234-266 static inline int sco_send_frame(struct Link Here
234
{
267
{
235
	struct sco_conn *conn = sco_pi(sk)->conn;
268
	struct sco_conn *conn = sco_pi(sk)->conn;
236
	struct sk_buff *skb;
269
	struct sk_buff *skb;
237
	int err, count;
270
	int err;
238
239
	/* Check outgoing MTU */
240
	if (len > conn->mtu)
241
		return -EINVAL;
242
271
243
	BT_DBG("sk %p len %d", sk, len);
272
	BT_DBG("sk %p len %d", sk, len);
244
273
245
	count = min_t(unsigned int, conn->mtu, len);
274
	if (!(skb = bt_skb_send_alloc(sk, len, msg->msg_flags & MSG_DONTWAIT, &err)))
246
	if (!(skb = bt_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err)))
247
		return err;
275
		return err;
248
276
249
	if (memcpy_fromiovec(skb_put(skb, count), msg->msg_iov, count)) {
277
	/* fix sk_wmem_alloc value : by default it is increased by  skb->truesize, but
278
	   we want it only increased by 1 */
279
	atomic_sub(skb->truesize - 1, &sk->sk_wmem_alloc);
280
	/* fix destructor */
281
	skb->destructor = sco_sock_wfree;
282
283
	if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
250
		err = -EFAULT;
284
		err = -EFAULT;
251
		goto fail;
285
		goto fail;
252
	}
286
	}
253
287
254
	if ((err = hci_send_sco(conn->hcon, skb)) < 0)
288
	err = hci_send_sco(conn->hcon, skb);
255
		return err;
289
290
	if (err < 0)
291
		goto fail;
256
292
257
	return count;
293
	return len;
258
294
259
fail:
295
fail:
260
	kfree_skb(skb);
296
	kfree_skb(skb);
261
	return err;
297
	return err;
262
}
298
}
263
299
300
static int sco_sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
301
{
302
	BT_DBG("sock %p, sk_rcvbuf %d, qlen %d", sk, sk->sk_rcvbuf, skb_queue_len(&sk->sk_receive_queue));
303
304
	if (skb_queue_len(&sk->sk_receive_queue) + 1 > (unsigned)sk->sk_rcvbuf)
305
		return -ENOMEM;
306
307
	skb->dev = NULL;
308
	skb->sk = sk;
309
	skb->destructor = NULL;
310
311
	skb_queue_tail(&sk->sk_receive_queue, skb);
312
313
	if (!sock_flag(sk, SOCK_DEAD))
314
		sk->sk_data_ready(sk, 1);
315
316
	return 0;
317
}
318
264
static inline void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb)
319
static inline void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb)
265
{
320
{
266
	struct sock *sk = sco_chan_get(conn);
321
	struct sock *sk = sco_chan_get(conn);
Lines 273-279 static inline void sco_recv_frame(struct Link Here
273
	if (sk->sk_state != BT_CONNECTED)
328
	if (sk->sk_state != BT_CONNECTED)
274
		goto drop;
329
		goto drop;
275
330
276
	if (!sock_queue_rcv_skb(sk, skb))
331
	if (!sco_sock_queue_rcv_skb(sk, skb))
277
		return;
332
		return;
278
333
279
drop:
334
drop:
Lines 328-334 static void sco_sock_destruct(struct soc Link Here
328
	BT_DBG("sk %p", sk);
383
	BT_DBG("sk %p", sk);
329
384
330
	skb_queue_purge(&sk->sk_receive_queue);
385
	skb_queue_purge(&sk->sk_receive_queue);
331
	skb_queue_purge(&sk->sk_write_queue);
332
}
386
}
333
387
334
static void sco_sock_cleanup_listen(struct sock *parent)
388
static void sco_sock_cleanup_listen(struct sock *parent)
Lines 426-431 static struct sock *sco_sock_alloc(struc Link Here
426
	INIT_LIST_HEAD(&bt_sk(sk)->accept_q);
480
	INIT_LIST_HEAD(&bt_sk(sk)->accept_q);
427
481
428
	sk->sk_destruct = sco_sock_destruct;
482
	sk->sk_destruct = sco_sock_destruct;
483
	sk->sk_write_space = sco_sock_write_space;
484
485
	sk->sk_sndbuf = DEFAULT_SCO_TXBUFS;
486
	sk->sk_rcvbuf = DEFAULT_SCO_RXBUFS;
429
	sk->sk_sndtimeo = SCO_CONN_TIMEOUT;
487
	sk->sk_sndtimeo = SCO_CONN_TIMEOUT;
430
488
431
	sock_reset_flag(sk, SOCK_ZAPPED);
489
	sock_reset_flag(sk, SOCK_ZAPPED);
Lines 656-661 static int sco_sock_sendmsg(struct kiocb Link Here
656
static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
714
static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
657
{
715
{
658
	struct sock *sk = sock->sk;
716
	struct sock *sk = sock->sk;
717
	u32 opt;
659
	int err = 0;
718
	int err = 0;
660
719
661
	BT_DBG("sk %p", sk);
720
	BT_DBG("sk %p", sk);
Lines 663-668 static int sco_sock_setsockopt(struct so Link Here
663
	lock_sock(sk);
722
	lock_sock(sk);
664
723
665
	switch (optname) {
724
	switch (optname) {
725
	case SO_SNDBUF:
726
		if (get_user(opt, (u32 __user *) optval)) {
727
			err = -EFAULT;
728
			break;
729
		}
730
		if (opt > MAX_SCO_TXBUFS) {
731
			err = -EINVAL;
732
			break;
733
		}
734
735
		sk->sk_sndbuf = opt;
736
		/* Wake up sending tasks if we upped the value */
737
		sk->sk_write_space(sk);
738
		break;
739
	case SO_RCVBUF:
740
		if (get_user(opt, (u32 __user *) optval)) {
741
			err = -EFAULT;
742
			break;
743
		}
744
		if (opt > MAX_SCO_RXBUFS) {
745
			err = -EINVAL;
746
			break;
747
		}
748
749
		sk->sk_rcvbuf = opt;
750
		break;
666
	default:
751
	default:
667
		err = -ENOPROTOOPT;
752
		err = -ENOPROTOOPT;
668
		break;
753
		break;
Lines 678-683 static int sco_sock_getsockopt(struct so Link Here
678
	struct sco_options opts;
763
	struct sco_options opts;
679
	struct sco_conninfo cinfo;
764
	struct sco_conninfo cinfo;
680
	int len, err = 0;
765
	int len, err = 0;
766
	int val;
681
767
682
	BT_DBG("sk %p", sk);
768
	BT_DBG("sk %p", sk);
683
769
Lines 687-692 static int sco_sock_getsockopt(struct so Link Here
687
	lock_sock(sk);
773
	lock_sock(sk);
688
774
689
	switch (optname) {
775
	switch (optname) {
776
	case SO_RCVBUF:
777
		val = sk->sk_rcvbuf;
778
779
		len = min_t(unsigned int, len, sizeof(val));
780
		if (copy_to_user(optval, (char *) &val, len))
781
			err = -EFAULT;
782
783
		break;
784
785
	case SO_SNDBUF:
786
		val = sk->sk_sndbuf;
787
788
		len = min_t(unsigned int, len, sizeof(val));
789
		if (copy_to_user(optval, (char *) &val, len))
790
			err = -EFAULT;
791
792
		break;
793
690
	case SCO_OPTIONS:
794
	case SCO_OPTIONS:
691
		if (sk->sk_state != BT_CONNECTED) {
795
		if (sk->sk_state != BT_CONNECTED) {
692
			err = -ENOTCONN;
796
			err = -ENOTCONN;
Lines 698-704 static int sco_sock_getsockopt(struct so Link Here
698
		BT_DBG("mtu %d", opts.mtu);
802
		BT_DBG("mtu %d", opts.mtu);
699
803
700
		len = min_t(unsigned int, len, sizeof(opts));
804
		len = min_t(unsigned int, len, sizeof(opts));
701
		if (copy_to_user(optval, (char *)&opts, len))
805
		if (copy_to_user(optval, (char *) &opts, len))
702
			err = -EFAULT;
806
			err = -EFAULT;
703
807
704
		break;
808
		break;
Lines 713-719 static int sco_sock_getsockopt(struct so Link Here
713
		memcpy(cinfo.dev_class, sco_pi(sk)->conn->hcon->dev_class, 3);
817
		memcpy(cinfo.dev_class, sco_pi(sk)->conn->hcon->dev_class, 3);
714
818
715
		len = min_t(unsigned int, len, sizeof(cinfo));
819
		len = min_t(unsigned int, len, sizeof(cinfo));
716
		if (copy_to_user(optval, (char *)&cinfo, len))
820
		if (copy_to_user(optval, (char *) &cinfo, len))
717
			err = -EFAULT;
821
			err = -EFAULT;
718
822
719
		break;
823
		break;

Return to bug 91558