aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_core.c4
-rw-r--r--net/bluetooth/l2cap.c73
2 files changed, 29 insertions, 48 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 1c9aef97f519..904f1e8a7a3b 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1260,7 +1260,7 @@ static void hci_add_acl_hdr(struct sk_buff *skb, __u16 handle, __u16 flags)
1260 hdr->dlen = cpu_to_le16(len); 1260 hdr->dlen = cpu_to_le16(len);
1261} 1261}
1262 1262
1263int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags) 1263void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
1264{ 1264{
1265 struct hci_dev *hdev = conn->hdev; 1265 struct hci_dev *hdev = conn->hdev;
1266 struct sk_buff *list; 1266 struct sk_buff *list;
@@ -1303,7 +1303,7 @@ int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
1303 1303
1304 tasklet_schedule(&hdev->tx_task); 1304 tasklet_schedule(&hdev->tx_task);
1305 1305
1306 return 0; 1306 return;
1307} 1307}
1308EXPORT_SYMBOL(hci_send_acl); 1308EXPORT_SYMBOL(hci_send_acl);
1309 1309
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 6b08f4d7c873..7e74d5be16e3 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -330,19 +330,19 @@ static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
330 return id; 330 return id;
331} 331}
332 332
333static inline int l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data) 333static inline void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
334{ 334{
335 struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data); 335 struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
336 336
337 BT_DBG("code 0x%2.2x", code); 337 BT_DBG("code 0x%2.2x", code);
338 338
339 if (!skb) 339 if (!skb)
340 return -ENOMEM; 340 return;
341 341
342 return hci_send_acl(conn->hcon, skb, 0); 342 hci_send_acl(conn->hcon, skb, 0);
343} 343}
344 344
345static inline int l2cap_send_sframe(struct l2cap_pinfo *pi, u16 control) 345static inline void l2cap_send_sframe(struct l2cap_pinfo *pi, u16 control)
346{ 346{
347 struct sk_buff *skb; 347 struct sk_buff *skb;
348 struct l2cap_hdr *lh; 348 struct l2cap_hdr *lh;
@@ -369,7 +369,7 @@ static inline int l2cap_send_sframe(struct l2cap_pinfo *pi, u16 control)
369 369
370 skb = bt_skb_alloc(count, GFP_ATOMIC); 370 skb = bt_skb_alloc(count, GFP_ATOMIC);
371 if (!skb) 371 if (!skb)
372 return -ENOMEM; 372 return;
373 373
374 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); 374 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
375 lh->len = cpu_to_le16(hlen - L2CAP_HDR_SIZE); 375 lh->len = cpu_to_le16(hlen - L2CAP_HDR_SIZE);
@@ -381,10 +381,10 @@ static inline int l2cap_send_sframe(struct l2cap_pinfo *pi, u16 control)
381 put_unaligned_le16(fcs, skb_put(skb, 2)); 381 put_unaligned_le16(fcs, skb_put(skb, 2));
382 } 382 }
383 383
384 return hci_send_acl(pi->conn->hcon, skb, 0); 384 hci_send_acl(pi->conn->hcon, skb, 0);
385} 385}
386 386
387static inline int l2cap_send_rr_or_rnr(struct l2cap_pinfo *pi, u16 control) 387static inline void l2cap_send_rr_or_rnr(struct l2cap_pinfo *pi, u16 control)
388{ 388{
389 if (pi->conn_state & L2CAP_CONN_LOCAL_BUSY) 389 if (pi->conn_state & L2CAP_CONN_LOCAL_BUSY)
390 control |= L2CAP_SUPER_RCV_NOT_READY; 390 control |= L2CAP_SUPER_RCV_NOT_READY;
@@ -393,7 +393,7 @@ static inline int l2cap_send_rr_or_rnr(struct l2cap_pinfo *pi, u16 control)
393 393
394 control |= pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 394 control |= pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT;
395 395
396 return l2cap_send_sframe(pi, control); 396 l2cap_send_sframe(pi, control);
397} 397}
398 398
399static void l2cap_do_start(struct sock *sk) 399static void l2cap_do_start(struct sock *sk)
@@ -1289,18 +1289,13 @@ static void l2cap_drop_acked_frames(struct sock *sk)
1289 return; 1289 return;
1290} 1290}
1291 1291
1292static inline int l2cap_do_send(struct sock *sk, struct sk_buff *skb) 1292static inline void l2cap_do_send(struct sock *sk, struct sk_buff *skb)
1293{ 1293{
1294 struct l2cap_pinfo *pi = l2cap_pi(sk); 1294 struct l2cap_pinfo *pi = l2cap_pi(sk);
1295 int err;
1296 1295
1297 BT_DBG("sk %p, skb %p len %d", sk, skb, skb->len); 1296 BT_DBG("sk %p, skb %p len %d", sk, skb, skb->len);
1298 1297
1299 err = hci_send_acl(pi->conn->hcon, skb, 0); 1298 hci_send_acl(pi->conn->hcon, skb, 0);
1300 if (err < 0)
1301 kfree_skb(skb);
1302
1303 return err;
1304} 1299}
1305 1300
1306static int l2cap_streaming_send(struct sock *sk) 1301static int l2cap_streaming_send(struct sock *sk)
@@ -1308,7 +1303,6 @@ static int l2cap_streaming_send(struct sock *sk)
1308 struct sk_buff *skb, *tx_skb; 1303 struct sk_buff *skb, *tx_skb;
1309 struct l2cap_pinfo *pi = l2cap_pi(sk); 1304 struct l2cap_pinfo *pi = l2cap_pi(sk);
1310 u16 control, fcs; 1305 u16 control, fcs;
1311 int err;
1312 1306
1313 while ((skb = sk->sk_send_head)) { 1307 while ((skb = sk->sk_send_head)) {
1314 tx_skb = skb_clone(skb, GFP_ATOMIC); 1308 tx_skb = skb_clone(skb, GFP_ATOMIC);
@@ -1322,11 +1316,7 @@ static int l2cap_streaming_send(struct sock *sk)
1322 put_unaligned_le16(fcs, tx_skb->data + tx_skb->len - 2); 1316 put_unaligned_le16(fcs, tx_skb->data + tx_skb->len - 2);
1323 } 1317 }
1324 1318
1325 err = l2cap_do_send(sk, tx_skb); 1319 l2cap_do_send(sk, tx_skb);
1326 if (err < 0) {
1327 l2cap_send_disconn_req(pi->conn, sk);
1328 return err;
1329 }
1330 1320
1331 pi->next_tx_seq = (pi->next_tx_seq + 1) % 64; 1321 pi->next_tx_seq = (pi->next_tx_seq + 1) % 64;
1332 1322
@@ -1346,7 +1336,6 @@ static int l2cap_retransmit_frame(struct sock *sk, u8 tx_seq)
1346 struct l2cap_pinfo *pi = l2cap_pi(sk); 1336 struct l2cap_pinfo *pi = l2cap_pi(sk);
1347 struct sk_buff *skb, *tx_skb; 1337 struct sk_buff *skb, *tx_skb;
1348 u16 control, fcs; 1338 u16 control, fcs;
1349 int err;
1350 1339
1351 skb = skb_peek(TX_QUEUE(sk)); 1340 skb = skb_peek(TX_QUEUE(sk));
1352 do { 1341 do {
@@ -1375,11 +1364,7 @@ static int l2cap_retransmit_frame(struct sock *sk, u8 tx_seq)
1375 put_unaligned_le16(fcs, tx_skb->data + tx_skb->len - 2); 1364 put_unaligned_le16(fcs, tx_skb->data + tx_skb->len - 2);
1376 } 1365 }
1377 1366
1378 err = l2cap_do_send(sk, tx_skb); 1367 l2cap_do_send(sk, tx_skb);
1379 if (err < 0) {
1380 l2cap_send_disconn_req(pi->conn, sk);
1381 return err;
1382 }
1383 break; 1368 break;
1384 } while(1); 1369 } while(1);
1385 return 0; 1370 return 0;
@@ -1390,7 +1375,7 @@ static int l2cap_ertm_send(struct sock *sk)
1390 struct sk_buff *skb, *tx_skb; 1375 struct sk_buff *skb, *tx_skb;
1391 struct l2cap_pinfo *pi = l2cap_pi(sk); 1376 struct l2cap_pinfo *pi = l2cap_pi(sk);
1392 u16 control, fcs; 1377 u16 control, fcs;
1393 int err, nsent = 0; 1378 int nsent = 0;
1394 1379
1395 if (pi->conn_state & L2CAP_CONN_WAIT_F) 1380 if (pi->conn_state & L2CAP_CONN_WAIT_F)
1396 return 0; 1381 return 0;
@@ -1423,11 +1408,8 @@ static int l2cap_ertm_send(struct sock *sk)
1423 put_unaligned_le16(fcs, skb->data + tx_skb->len - 2); 1408 put_unaligned_le16(fcs, skb->data + tx_skb->len - 2);
1424 } 1409 }
1425 1410
1426 err = l2cap_do_send(sk, tx_skb); 1411 l2cap_do_send(sk, tx_skb);
1427 if (err < 0) { 1412
1428 l2cap_send_disconn_req(pi->conn, sk);
1429 return err;
1430 }
1431 __mod_retrans_timer(); 1413 __mod_retrans_timer();
1432 1414
1433 bt_cb(skb)->tx_seq = pi->next_tx_seq; 1415 bt_cb(skb)->tx_seq = pi->next_tx_seq;
@@ -1447,7 +1429,7 @@ static int l2cap_ertm_send(struct sock *sk)
1447 return nsent; 1429 return nsent;
1448} 1430}
1449 1431
1450static int l2cap_send_ack(struct l2cap_pinfo *pi) 1432static void l2cap_send_ack(struct l2cap_pinfo *pi)
1451{ 1433{
1452 struct sock *sk = (struct sock *)pi; 1434 struct sock *sk = (struct sock *)pi;
1453 u16 control = 0; 1435 u16 control = 0;
@@ -1456,15 +1438,15 @@ static int l2cap_send_ack(struct l2cap_pinfo *pi)
1456 1438
1457 if (pi->conn_state & L2CAP_CONN_LOCAL_BUSY) { 1439 if (pi->conn_state & L2CAP_CONN_LOCAL_BUSY) {
1458 control |= L2CAP_SUPER_RCV_NOT_READY; 1440 control |= L2CAP_SUPER_RCV_NOT_READY;
1459 return l2cap_send_sframe(pi, control); 1441 l2cap_send_sframe(pi, control);
1442 return;
1460 } else if (l2cap_ertm_send(sk) == 0) { 1443 } else if (l2cap_ertm_send(sk) == 0) {
1461 control |= L2CAP_SUPER_RCV_READY; 1444 control |= L2CAP_SUPER_RCV_READY;
1462 return l2cap_send_sframe(pi, control); 1445 l2cap_send_sframe(pi, control);
1463 } 1446 }
1464 return 0;
1465} 1447}
1466 1448
1467static int l2cap_send_srejtail(struct sock *sk) 1449static void l2cap_send_srejtail(struct sock *sk)
1468{ 1450{
1469 struct srej_list *tail; 1451 struct srej_list *tail;
1470 u16 control; 1452 u16 control;
@@ -1476,8 +1458,6 @@ static int l2cap_send_srejtail(struct sock *sk)
1476 control |= tail->tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; 1458 control |= tail->tx_seq << L2CAP_CTRL_REQSEQ_SHIFT;
1477 1459
1478 l2cap_send_sframe(l2cap_pi(sk), control); 1460 l2cap_send_sframe(l2cap_pi(sk), control);
1479
1480 return 0;
1481} 1461}
1482 1462
1483static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, int len, int count, struct sk_buff *skb) 1463static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, int len, int count, struct sk_buff *skb)
@@ -1687,10 +1667,12 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
1687 /* Connectionless channel */ 1667 /* Connectionless channel */
1688 if (sk->sk_type == SOCK_DGRAM) { 1668 if (sk->sk_type == SOCK_DGRAM) {
1689 skb = l2cap_create_connless_pdu(sk, msg, len); 1669 skb = l2cap_create_connless_pdu(sk, msg, len);
1690 if (IS_ERR(skb)) 1670 if (IS_ERR(skb)) {
1691 err = PTR_ERR(skb); 1671 err = PTR_ERR(skb);
1692 else 1672 } else {
1693 err = l2cap_do_send(sk, skb); 1673 l2cap_do_send(sk, skb);
1674 err = len;
1675 }
1694 goto done; 1676 goto done;
1695 } 1677 }
1696 1678
@@ -1709,9 +1691,8 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
1709 goto done; 1691 goto done;
1710 } 1692 }
1711 1693
1712 err = l2cap_do_send(sk, skb); 1694 l2cap_do_send(sk, skb);
1713 if (!err) 1695 err = len;
1714 err = len;
1715 break; 1696 break;
1716 1697
1717 case L2CAP_MODE_ERTM: 1698 case L2CAP_MODE_ERTM: