aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/l2cap_core.c
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-04-13 19:23:55 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-04-28 00:10:00 -0400
commit8c1d787be4b62d2d1b6f04953eca4bcf7c839d44 (patch)
treee2a35c5cb81cc5109c13c2747b039fa05ea55a6e /net/bluetooth/l2cap_core.c
parentfe4128e0aabc3c748786c00da21e6eff9d3aeddb (diff)
Bluetooth: Move conn to struct l2cap_chan
There is no need to the socket deal directly with the channel, most of the time it cares about the channel only. Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/l2cap_core.c')
-rw-r--r--net/bluetooth/l2cap_core.c92
1 files changed, 40 insertions, 52 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index dd726bdd6e02..8562ac1ba947 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -169,7 +169,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
169 169
170 conn->disc_reason = 0x13; 170 conn->disc_reason = 0x13;
171 171
172 l2cap_pi(sk)->conn = conn; 172 chan->conn = conn;
173 173
174 if (sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) { 174 if (sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) {
175 if (conn->hcon->type == LE_LINK) { 175 if (conn->hcon->type == LE_LINK) {
@@ -204,7 +204,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
204void l2cap_chan_del(struct l2cap_chan *chan, int err) 204void l2cap_chan_del(struct l2cap_chan *chan, int err)
205{ 205{
206 struct sock *sk = chan->sk; 206 struct sock *sk = chan->sk;
207 struct l2cap_conn *conn = l2cap_pi(sk)->conn; 207 struct l2cap_conn *conn = chan->conn;
208 struct sock *parent = bt_sk(sk)->parent; 208 struct sock *parent = bt_sk(sk)->parent;
209 209
210 l2cap_sock_clear_timer(sk); 210 l2cap_sock_clear_timer(sk);
@@ -218,7 +218,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
218 write_unlock_bh(&conn->chan_lock); 218 write_unlock_bh(&conn->chan_lock);
219 __sock_put(sk); 219 __sock_put(sk);
220 220
221 l2cap_pi(sk)->conn = NULL; 221 chan->conn = NULL;
222 hci_conn_put(conn->hcon); 222 hci_conn_put(conn->hcon);
223 } 223 }
224 224
@@ -296,7 +296,7 @@ static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan)
296/* Service level security */ 296/* Service level security */
297static inline int l2cap_check_security(struct l2cap_chan *chan) 297static inline int l2cap_check_security(struct l2cap_chan *chan)
298{ 298{
299 struct l2cap_conn *conn = l2cap_pi(chan->sk)->conn; 299 struct l2cap_conn *conn = chan->conn;
300 __u8 auth_type; 300 __u8 auth_type;
301 301
302 auth_type = l2cap_get_auth_type(chan); 302 auth_type = l2cap_get_auth_type(chan);
@@ -349,7 +349,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control)
349 struct sk_buff *skb; 349 struct sk_buff *skb;
350 struct l2cap_hdr *lh; 350 struct l2cap_hdr *lh;
351 struct l2cap_pinfo *pi = l2cap_pi(chan->sk); 351 struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
352 struct l2cap_conn *conn = pi->conn; 352 struct l2cap_conn *conn = chan->conn;
353 struct sock *sk = (struct sock *)pi; 353 struct sock *sk = (struct sock *)pi;
354 int count, hlen = L2CAP_HDR_SIZE + 2; 354 int count, hlen = L2CAP_HDR_SIZE + 2;
355 u8 flags; 355 u8 flags;
@@ -394,7 +394,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control)
394 else 394 else
395 flags = ACL_START; 395 flags = ACL_START;
396 396
397 hci_send_acl(pi->conn->hcon, skb, flags); 397 hci_send_acl(chan->conn->hcon, skb, flags);
398} 398}
399 399
400static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control) 400static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control)
@@ -417,8 +417,7 @@ static inline int __l2cap_no_conn_pending(struct l2cap_chan *chan)
417 417
418static void l2cap_do_start(struct l2cap_chan *chan) 418static void l2cap_do_start(struct l2cap_chan *chan)
419{ 419{
420 struct sock *sk = chan->sk; 420 struct l2cap_conn *conn = chan->conn;
421 struct l2cap_conn *conn = l2cap_pi(sk)->conn;
422 421
423 if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) { 422 if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) {
424 if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE)) 423 if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE))
@@ -920,12 +919,13 @@ done:
920 919
921int __l2cap_wait_ack(struct sock *sk) 920int __l2cap_wait_ack(struct sock *sk)
922{ 921{
922 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
923 DECLARE_WAITQUEUE(wait, current); 923 DECLARE_WAITQUEUE(wait, current);
924 int err = 0; 924 int err = 0;
925 int timeo = HZ/5; 925 int timeo = HZ/5;
926 926
927 add_wait_queue(sk_sleep(sk), &wait); 927 add_wait_queue(sk_sleep(sk), &wait);
928 while ((l2cap_pi(sk)->chan->unacked_frames > 0 && l2cap_pi(sk)->conn)) { 928 while ((chan->unacked_frames > 0 && chan->conn)) {
929 set_current_state(TASK_INTERRUPTIBLE); 929 set_current_state(TASK_INTERRUPTIBLE);
930 930
931 if (!timeo) 931 if (!timeo)
@@ -958,7 +958,7 @@ static void l2cap_monitor_timeout(unsigned long arg)
958 958
959 bh_lock_sock(sk); 959 bh_lock_sock(sk);
960 if (chan->retry_count >= chan->remote_max_tx) { 960 if (chan->retry_count >= chan->remote_max_tx) {
961 l2cap_send_disconn_req(l2cap_pi(sk)->conn, chan, ECONNABORTED); 961 l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED);
962 bh_unlock_sock(sk); 962 bh_unlock_sock(sk);
963 return; 963 return;
964 } 964 }
@@ -1008,8 +1008,7 @@ static void l2cap_drop_acked_frames(struct l2cap_chan *chan)
1008 1008
1009void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) 1009void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb)
1010{ 1010{
1011 struct sock *sk = chan->sk; 1011 struct hci_conn *hcon = chan->conn->hcon;
1012 struct hci_conn *hcon = l2cap_pi(sk)->conn->hcon;
1013 u16 flags; 1012 u16 flags;
1014 1013
1015 BT_DBG("chan %p, skb %p len %d", chan, skb, skb->len); 1014 BT_DBG("chan %p, skb %p len %d", chan, skb, skb->len);
@@ -1045,8 +1044,6 @@ void l2cap_streaming_send(struct l2cap_chan *chan)
1045 1044
1046static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) 1045static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq)
1047{ 1046{
1048 struct sock *sk = chan->sk;
1049 struct l2cap_pinfo *pi = l2cap_pi(sk);
1050 struct sk_buff *skb, *tx_skb; 1047 struct sk_buff *skb, *tx_skb;
1051 u16 control, fcs; 1048 u16 control, fcs;
1052 1049
@@ -1065,7 +1062,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq)
1065 1062
1066 if (chan->remote_max_tx && 1063 if (chan->remote_max_tx &&
1067 bt_cb(skb)->retries == chan->remote_max_tx) { 1064 bt_cb(skb)->retries == chan->remote_max_tx) {
1068 l2cap_send_disconn_req(pi->conn, chan, ECONNABORTED); 1065 l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED);
1069 return; 1066 return;
1070 } 1067 }
1071 1068
@@ -1096,7 +1093,6 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
1096{ 1093{
1097 struct sk_buff *skb, *tx_skb; 1094 struct sk_buff *skb, *tx_skb;
1098 struct sock *sk = chan->sk; 1095 struct sock *sk = chan->sk;
1099 struct l2cap_pinfo *pi = l2cap_pi(sk);
1100 u16 control, fcs; 1096 u16 control, fcs;
1101 int nsent = 0; 1097 int nsent = 0;
1102 1098
@@ -1107,7 +1103,7 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
1107 1103
1108 if (chan->remote_max_tx && 1104 if (chan->remote_max_tx &&
1109 bt_cb(skb)->retries == chan->remote_max_tx) { 1105 bt_cb(skb)->retries == chan->remote_max_tx) {
1110 l2cap_send_disconn_req(pi->conn, chan, ECONNABORTED); 1106 l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED);
1111 break; 1107 break;
1112 } 1108 }
1113 1109
@@ -1203,7 +1199,7 @@ static void l2cap_send_srejtail(struct l2cap_chan *chan)
1203 1199
1204static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, int len, int count, struct sk_buff *skb) 1200static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, int len, int count, struct sk_buff *skb)
1205{ 1201{
1206 struct l2cap_conn *conn = l2cap_pi(sk)->conn; 1202 struct l2cap_conn *conn = l2cap_pi(sk)->chan->conn;
1207 struct sk_buff **frag; 1203 struct sk_buff **frag;
1208 int err, sent = 0; 1204 int err, sent = 0;
1209 1205
@@ -1236,7 +1232,7 @@ static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, in
1236struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len) 1232struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
1237{ 1233{
1238 struct sock *sk = chan->sk; 1234 struct sock *sk = chan->sk;
1239 struct l2cap_conn *conn = l2cap_pi(sk)->conn; 1235 struct l2cap_conn *conn = chan->conn;
1240 struct sk_buff *skb; 1236 struct sk_buff *skb;
1241 int err, count, hlen = L2CAP_HDR_SIZE + 2; 1237 int err, count, hlen = L2CAP_HDR_SIZE + 2;
1242 struct l2cap_hdr *lh; 1238 struct l2cap_hdr *lh;
@@ -1266,7 +1262,7 @@ struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr
1266struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len) 1262struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
1267{ 1263{
1268 struct sock *sk = chan->sk; 1264 struct sock *sk = chan->sk;
1269 struct l2cap_conn *conn = l2cap_pi(sk)->conn; 1265 struct l2cap_conn *conn = chan->conn;
1270 struct sk_buff *skb; 1266 struct sk_buff *skb;
1271 int err, count, hlen = L2CAP_HDR_SIZE; 1267 int err, count, hlen = L2CAP_HDR_SIZE;
1272 struct l2cap_hdr *lh; 1268 struct l2cap_hdr *lh;
@@ -1295,7 +1291,7 @@ struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *m
1295struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen) 1291struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen)
1296{ 1292{
1297 struct sock *sk = chan->sk; 1293 struct sock *sk = chan->sk;
1298 struct l2cap_conn *conn = l2cap_pi(sk)->conn; 1294 struct l2cap_conn *conn = chan->conn;
1299 struct sk_buff *skb; 1295 struct sk_buff *skb;
1300 int err, count, hlen = L2CAP_HDR_SIZE + 2; 1296 int err, count, hlen = L2CAP_HDR_SIZE + 2;
1301 struct l2cap_hdr *lh; 1297 struct l2cap_hdr *lh;
@@ -1611,7 +1607,6 @@ static inline __u8 l2cap_select_mode(__u8 mode, __u16 remote_feat_mask)
1611 1607
1612static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) 1608static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
1613{ 1609{
1614 struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
1615 struct l2cap_conf_req *req = data; 1610 struct l2cap_conf_req *req = data;
1616 struct l2cap_conf_rfc rfc = { .mode = chan->mode }; 1611 struct l2cap_conf_rfc rfc = { .mode = chan->mode };
1617 void *ptr = req->data; 1612 void *ptr = req->data;
@@ -1629,7 +1624,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
1629 1624
1630 /* fall through */ 1625 /* fall through */
1631 default: 1626 default:
1632 chan->mode = l2cap_select_mode(rfc.mode, pi->conn->feat_mask); 1627 chan->mode = l2cap_select_mode(rfc.mode, chan->conn->feat_mask);
1633 break; 1628 break;
1634 } 1629 }
1635 1630
@@ -1639,8 +1634,8 @@ done:
1639 1634
1640 switch (chan->mode) { 1635 switch (chan->mode) {
1641 case L2CAP_MODE_BASIC: 1636 case L2CAP_MODE_BASIC:
1642 if (!(pi->conn->feat_mask & L2CAP_FEAT_ERTM) && 1637 if (!(chan->conn->feat_mask & L2CAP_FEAT_ERTM) &&
1643 !(pi->conn->feat_mask & L2CAP_FEAT_STREAMING)) 1638 !(chan->conn->feat_mask & L2CAP_FEAT_STREAMING))
1644 break; 1639 break;
1645 1640
1646 rfc.mode = L2CAP_MODE_BASIC; 1641 rfc.mode = L2CAP_MODE_BASIC;
@@ -1661,13 +1656,13 @@ done:
1661 rfc.retrans_timeout = 0; 1656 rfc.retrans_timeout = 0;
1662 rfc.monitor_timeout = 0; 1657 rfc.monitor_timeout = 0;
1663 rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE); 1658 rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE);
1664 if (L2CAP_DEFAULT_MAX_PDU_SIZE > pi->conn->mtu - 10) 1659 if (L2CAP_DEFAULT_MAX_PDU_SIZE > chan->conn->mtu - 10)
1665 rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10); 1660 rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10);
1666 1661
1667 l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), 1662 l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
1668 (unsigned long) &rfc); 1663 (unsigned long) &rfc);
1669 1664
1670 if (!(pi->conn->feat_mask & L2CAP_FEAT_FCS)) 1665 if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS))
1671 break; 1666 break;
1672 1667
1673 if (chan->fcs == L2CAP_FCS_NONE || 1668 if (chan->fcs == L2CAP_FCS_NONE ||
@@ -1684,13 +1679,13 @@ done:
1684 rfc.retrans_timeout = 0; 1679 rfc.retrans_timeout = 0;
1685 rfc.monitor_timeout = 0; 1680 rfc.monitor_timeout = 0;
1686 rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE); 1681 rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE);
1687 if (L2CAP_DEFAULT_MAX_PDU_SIZE > pi->conn->mtu - 10) 1682 if (L2CAP_DEFAULT_MAX_PDU_SIZE > chan->conn->mtu - 10)
1688 rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10); 1683 rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10);
1689 1684
1690 l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), 1685 l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
1691 (unsigned long) &rfc); 1686 (unsigned long) &rfc);
1692 1687
1693 if (!(pi->conn->feat_mask & L2CAP_FEAT_FCS)) 1688 if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS))
1694 break; 1689 break;
1695 1690
1696 if (chan->fcs == L2CAP_FCS_NONE || 1691 if (chan->fcs == L2CAP_FCS_NONE ||
@@ -1709,7 +1704,6 @@ done:
1709 1704
1710static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) 1705static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
1711{ 1706{
1712 struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
1713 struct l2cap_conf_rsp *rsp = data; 1707 struct l2cap_conf_rsp *rsp = data;
1714 void *ptr = rsp->data; 1708 void *ptr = rsp->data;
1715 void *req = chan->conf_req; 1709 void *req = chan->conf_req;
@@ -1769,7 +1763,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
1769 case L2CAP_MODE_ERTM: 1763 case L2CAP_MODE_ERTM:
1770 if (!(chan->conf_state & L2CAP_CONF_STATE2_DEVICE)) { 1764 if (!(chan->conf_state & L2CAP_CONF_STATE2_DEVICE)) {
1771 chan->mode = l2cap_select_mode(rfc.mode, 1765 chan->mode = l2cap_select_mode(rfc.mode,
1772 pi->conn->feat_mask); 1766 chan->conn->feat_mask);
1773 break; 1767 break;
1774 } 1768 }
1775 1769
@@ -1814,8 +1808,8 @@ done:
1814 chan->remote_tx_win = rfc.txwin_size; 1808 chan->remote_tx_win = rfc.txwin_size;
1815 chan->remote_max_tx = rfc.max_transmit; 1809 chan->remote_max_tx = rfc.max_transmit;
1816 1810
1817 if (le16_to_cpu(rfc.max_pdu_size) > pi->conn->mtu - 10) 1811 if (le16_to_cpu(rfc.max_pdu_size) > chan->conn->mtu - 10)
1818 rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10); 1812 rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10);
1819 1813
1820 chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); 1814 chan->remote_mps = le16_to_cpu(rfc.max_pdu_size);
1821 1815
@@ -1832,8 +1826,8 @@ done:
1832 break; 1826 break;
1833 1827
1834 case L2CAP_MODE_STREAMING: 1828 case L2CAP_MODE_STREAMING:
1835 if (le16_to_cpu(rfc.max_pdu_size) > pi->conn->mtu - 10) 1829 if (le16_to_cpu(rfc.max_pdu_size) > chan->conn->mtu - 10)
1836 rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10); 1830 rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10);
1837 1831
1838 chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); 1832 chan->remote_mps = le16_to_cpu(rfc.max_pdu_size);
1839 1833
@@ -1943,15 +1937,12 @@ static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, u16 result,
1943 return ptr - data; 1937 return ptr - data;
1944} 1938}
1945 1939
1946void __l2cap_connect_rsp_defer(struct sock *sk) 1940void __l2cap_connect_rsp_defer(struct l2cap_chan *chan)
1947{ 1941{
1948 struct l2cap_conn_rsp rsp; 1942 struct l2cap_conn_rsp rsp;
1949 struct l2cap_conn *conn = l2cap_pi(sk)->conn; 1943 struct l2cap_conn *conn = chan->conn;
1950 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
1951 u8 buf[128]; 1944 u8 buf[128];
1952 1945
1953 sk->sk_state = BT_CONFIG;
1954
1955 rsp.scid = cpu_to_le16(chan->dcid); 1946 rsp.scid = cpu_to_le16(chan->dcid);
1956 rsp.dcid = cpu_to_le16(chan->scid); 1947 rsp.dcid = cpu_to_le16(chan->scid);
1957 rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS); 1948 rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS);
@@ -2856,7 +2847,6 @@ static int l2cap_add_to_srej_queue(struct l2cap_chan *chan, struct sk_buff *skb,
2856 2847
2857static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u16 control) 2848static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u16 control)
2858{ 2849{
2859 struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
2860 struct sk_buff *_skb; 2850 struct sk_buff *_skb;
2861 int err; 2851 int err;
2862 2852
@@ -2957,7 +2947,7 @@ drop:
2957 chan->sdu = NULL; 2947 chan->sdu = NULL;
2958 2948
2959disconnect: 2949disconnect:
2960 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); 2950 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
2961 kfree_skb(skb); 2951 kfree_skb(skb);
2962 return 0; 2952 return 0;
2963} 2953}
@@ -3018,7 +3008,7 @@ static void l2cap_busy_work(struct work_struct *work)
3018 3008
3019 if (n_tries++ > L2CAP_LOCAL_BUSY_TRIES) { 3009 if (n_tries++ > L2CAP_LOCAL_BUSY_TRIES) {
3020 err = -EBUSY; 3010 err = -EBUSY;
3021 l2cap_send_disconn_req(l2cap_pi(sk)->conn, chan, EBUSY); 3011 l2cap_send_disconn_req(chan->conn, chan, EBUSY);
3022 break; 3012 break;
3023 } 3013 }
3024 3014
@@ -3236,7 +3226,6 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq)
3236 3226
3237static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) 3227static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb)
3238{ 3228{
3239 struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
3240 u8 tx_seq = __get_txseq(rx_control); 3229 u8 tx_seq = __get_txseq(rx_control);
3241 u8 req_seq = __get_reqseq(rx_control); 3230 u8 req_seq = __get_reqseq(rx_control);
3242 u8 sar = rx_control >> L2CAP_CTRL_SAR_SHIFT; 3231 u8 sar = rx_control >> L2CAP_CTRL_SAR_SHIFT;
@@ -3267,7 +3256,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
3267 3256
3268 /* invalid tx_seq */ 3257 /* invalid tx_seq */
3269 if (tx_seq_offset >= chan->tx_win) { 3258 if (tx_seq_offset >= chan->tx_win) {
3270 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); 3259 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
3271 goto drop; 3260 goto drop;
3272 } 3261 }
3273 3262
@@ -3534,7 +3523,6 @@ static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_cont
3534static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) 3523static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
3535{ 3524{
3536 struct l2cap_chan *chan = l2cap_pi(sk)->chan; 3525 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
3537 struct l2cap_pinfo *pi = l2cap_pi(sk);
3538 u16 control; 3526 u16 control;
3539 u8 req_seq; 3527 u8 req_seq;
3540 int len, next_tx_seq_offset, req_seq_offset; 3528 int len, next_tx_seq_offset, req_seq_offset;
@@ -3558,7 +3546,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
3558 len -= 2; 3546 len -= 2;
3559 3547
3560 if (len > chan->mps) { 3548 if (len > chan->mps) {
3561 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); 3549 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
3562 goto drop; 3550 goto drop;
3563 } 3551 }
3564 3552
@@ -3574,13 +3562,13 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
3574 3562
3575 /* check for invalid req-seq */ 3563 /* check for invalid req-seq */
3576 if (req_seq_offset > next_tx_seq_offset) { 3564 if (req_seq_offset > next_tx_seq_offset) {
3577 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); 3565 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
3578 goto drop; 3566 goto drop;
3579 } 3567 }
3580 3568
3581 if (__is_iframe(control)) { 3569 if (__is_iframe(control)) {
3582 if (len < 0) { 3570 if (len < 0) {
3583 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); 3571 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
3584 goto drop; 3572 goto drop;
3585 } 3573 }
3586 3574
@@ -3588,7 +3576,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
3588 } else { 3576 } else {
3589 if (len != 0) { 3577 if (len != 0) {
3590 BT_ERR("%d", len); 3578 BT_ERR("%d", len);
3591 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); 3579 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
3592 goto drop; 3580 goto drop;
3593 } 3581 }
3594 3582