aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/rfcomm/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/rfcomm/core.c')
-rw-r--r--net/bluetooth/rfcomm/core.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 278c8676906..94f45736056 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -1,4 +1,4 @@
1/* 1/*
2 RFCOMM implementation for Linux Bluetooth stack (BlueZ). 2 RFCOMM implementation for Linux Bluetooth stack (BlueZ).
3 Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com> 3 Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
4 Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org> 4 Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org>
@@ -11,13 +11,13 @@
11 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 12 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
13 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 13 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
14 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 14 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
15 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 18
19 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 19 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
20 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 20 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
21 SOFTWARE IS DISCLAIMED. 21 SOFTWARE IS DISCLAIMED.
22*/ 22*/
23 23
@@ -134,7 +134,7 @@ static inline void rfcomm_session_put(struct rfcomm_session *s)
134/* ---- RFCOMM FCS computation ---- */ 134/* ---- RFCOMM FCS computation ---- */
135 135
136/* reversed, 8-bit, poly=0x07 */ 136/* reversed, 8-bit, poly=0x07 */
137static unsigned char rfcomm_crc_table[256] = { 137static unsigned char rfcomm_crc_table[256] = {
138 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75, 138 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75,
139 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b, 139 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b,
140 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69, 140 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69,
@@ -179,13 +179,13 @@ static unsigned char rfcomm_crc_table[256] = {
179/* CRC on 2 bytes */ 179/* CRC on 2 bytes */
180#define __crc(data) (rfcomm_crc_table[rfcomm_crc_table[0xff ^ data[0]] ^ data[1]]) 180#define __crc(data) (rfcomm_crc_table[rfcomm_crc_table[0xff ^ data[0]] ^ data[1]])
181 181
182/* FCS on 2 bytes */ 182/* FCS on 2 bytes */
183static inline u8 __fcs(u8 *data) 183static inline u8 __fcs(u8 *data)
184{ 184{
185 return (0xff - __crc(data)); 185 return (0xff - __crc(data));
186} 186}
187 187
188/* FCS on 3 bytes */ 188/* FCS on 3 bytes */
189static inline u8 __fcs2(u8 *data) 189static inline u8 __fcs2(u8 *data)
190{ 190{
191 return (0xff - rfcomm_crc_table[__crc(data) ^ data[2]]); 191 return (0xff - rfcomm_crc_table[__crc(data) ^ data[2]]);
@@ -288,7 +288,7 @@ struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio)
288 atomic_set(&d->refcnt, 1); 288 atomic_set(&d->refcnt, 1);
289 289
290 rfcomm_dlc_clear_state(d); 290 rfcomm_dlc_clear_state(d);
291 291
292 BT_DBG("%p", d); 292 BT_DBG("%p", d);
293 293
294 return d; 294 return d;
@@ -345,7 +345,7 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst,
345 int err = 0; 345 int err = 0;
346 u8 dlci; 346 u8 dlci;
347 347
348 BT_DBG("dlc %p state %ld %s %s channel %d", 348 BT_DBG("dlc %p state %ld %s %s channel %d",
349 d, d->state, batostr(src), batostr(dst), channel); 349 d, d->state, batostr(src), batostr(dst), channel);
350 350
351 if (channel < 1 || channel > 30) 351 if (channel < 1 || channel > 30)
@@ -489,21 +489,21 @@ void fastcall __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d)
489 rfcomm_schedule(RFCOMM_SCHED_TX); 489 rfcomm_schedule(RFCOMM_SCHED_TX);
490} 490}
491 491
492/* 492/*
493 Set/get modem status functions use _local_ status i.e. what we report 493 Set/get modem status functions use _local_ status i.e. what we report
494 to the other side. 494 to the other side.
495 Remote status is provided by dlc->modem_status() callback. 495 Remote status is provided by dlc->modem_status() callback.
496 */ 496 */
497int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig) 497int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig)
498{ 498{
499 BT_DBG("dlc %p state %ld v24_sig 0x%x", 499 BT_DBG("dlc %p state %ld v24_sig 0x%x",
500 d, d->state, v24_sig); 500 d, d->state, v24_sig);
501 501
502 if (test_bit(RFCOMM_RX_THROTTLED, &d->flags)) 502 if (test_bit(RFCOMM_RX_THROTTLED, &d->flags))
503 v24_sig |= RFCOMM_V24_FC; 503 v24_sig |= RFCOMM_V24_FC;
504 else 504 else
505 v24_sig &= ~RFCOMM_V24_FC; 505 v24_sig &= ~RFCOMM_V24_FC;
506 506
507 d->v24_sig = v24_sig; 507 d->v24_sig = v24_sig;
508 508
509 if (!test_and_set_bit(RFCOMM_MSC_PENDING, &d->flags)) 509 if (!test_and_set_bit(RFCOMM_MSC_PENDING, &d->flags))
@@ -514,7 +514,7 @@ int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig)
514 514
515int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig) 515int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig)
516{ 516{
517 BT_DBG("dlc %p state %ld v24_sig 0x%x", 517 BT_DBG("dlc %p state %ld v24_sig 0x%x",
518 d, d->state, d->v24_sig); 518 d, d->state, d->v24_sig);
519 519
520 *v24_sig = d->v24_sig; 520 *v24_sig = d->v24_sig;
@@ -576,7 +576,7 @@ static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst)
576 struct bt_sock *sk; 576 struct bt_sock *sk;
577 list_for_each_safe(p, n, &session_list) { 577 list_for_each_safe(p, n, &session_list) {
578 s = list_entry(p, struct rfcomm_session, list); 578 s = list_entry(p, struct rfcomm_session, list);
579 sk = bt_sk(s->sock->sk); 579 sk = bt_sk(s->sock->sk);
580 580
581 if ((!bacmp(src, BDADDR_ANY) || !bacmp(&sk->src, src)) && 581 if ((!bacmp(src, BDADDR_ANY) || !bacmp(&sk->src, src)) &&
582 !bacmp(&sk->dst, dst)) 582 !bacmp(&sk->dst, dst))
@@ -825,7 +825,7 @@ static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d
825 825
826int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, 826int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
827 u8 bit_rate, u8 data_bits, u8 stop_bits, 827 u8 bit_rate, u8 data_bits, u8 stop_bits,
828 u8 parity, u8 flow_ctrl_settings, 828 u8 parity, u8 flow_ctrl_settings,
829 u8 xon_char, u8 xoff_char, u16 param_mask) 829 u8 xon_char, u8 xoff_char, u16 param_mask)
830{ 830{
831 struct rfcomm_hdr *hdr; 831 struct rfcomm_hdr *hdr;
@@ -834,8 +834,8 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
834 u8 buf[16], *ptr = buf; 834 u8 buf[16], *ptr = buf;
835 835
836 BT_DBG("%p cr %d dlci %d bit_r 0x%x data_b 0x%x stop_b 0x%x parity 0x%x" 836 BT_DBG("%p cr %d dlci %d bit_r 0x%x data_b 0x%x stop_b 0x%x parity 0x%x"
837 " flwc_s 0x%x xon_c 0x%x xoff_c 0x%x p_mask 0x%x", 837 " flwc_s 0x%x xon_c 0x%x xoff_c 0x%x p_mask 0x%x",
838 s, cr, dlci, bit_rate, data_bits, stop_bits, parity, 838 s, cr, dlci, bit_rate, data_bits, stop_bits, parity,
839 flow_ctrl_settings, xon_char, xoff_char, param_mask); 839 flow_ctrl_settings, xon_char, xoff_char, param_mask);
840 840
841 hdr = (void *) ptr; ptr += sizeof(*hdr); 841 hdr = (void *) ptr; ptr += sizeof(*hdr);
@@ -1120,9 +1120,9 @@ static int rfcomm_recv_disc(struct rfcomm_session *s, u8 dlci)
1120 1120
1121 d->state = BT_CLOSED; 1121 d->state = BT_CLOSED;
1122 __rfcomm_dlc_close(d, err); 1122 __rfcomm_dlc_close(d, err);
1123 } else 1123 } else
1124 rfcomm_send_dm(s, dlci); 1124 rfcomm_send_dm(s, dlci);
1125 1125
1126 } else { 1126 } else {
1127 rfcomm_send_ua(s, 0); 1127 rfcomm_send_ua(s, 0);
1128 1128
@@ -1230,7 +1230,7 @@ static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn)
1230{ 1230{
1231 struct rfcomm_session *s = d->session; 1231 struct rfcomm_session *s = d->session;
1232 1232
1233 BT_DBG("dlc %p state %ld dlci %d mtu %d fc 0x%x credits %d", 1233 BT_DBG("dlc %p state %ld dlci %d mtu %d fc 0x%x credits %d",
1234 d, d->state, d->dlci, pn->mtu, pn->flow_ctrl, pn->credits); 1234 d, d->state, d->dlci, pn->mtu, pn->flow_ctrl, pn->credits);
1235 1235
1236 if ((pn->flow_ctrl == 0xf0 && s->cfc != RFCOMM_CFC_DISABLED) || 1236 if ((pn->flow_ctrl == 0xf0 && s->cfc != RFCOMM_CFC_DISABLED) ||
@@ -1454,7 +1454,7 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb
1454 if (d->modem_status) 1454 if (d->modem_status)
1455 d->modem_status(d, msc->v24_sig); 1455 d->modem_status(d, msc->v24_sig);
1456 rfcomm_dlc_unlock(d); 1456 rfcomm_dlc_unlock(d);
1457 1457
1458 rfcomm_send_msc(s, 0, dlci, msc->v24_sig); 1458 rfcomm_send_msc(s, 0, dlci, msc->v24_sig);
1459 1459
1460 d->mscex |= RFCOMM_MSCEX_RX; 1460 d->mscex |= RFCOMM_MSCEX_RX;
@@ -1641,18 +1641,18 @@ static inline int rfcomm_process_tx(struct rfcomm_dlc *d)
1641 struct sk_buff *skb; 1641 struct sk_buff *skb;
1642 int err; 1642 int err;
1643 1643
1644 BT_DBG("dlc %p state %ld cfc %d rx_credits %d tx_credits %d", 1644 BT_DBG("dlc %p state %ld cfc %d rx_credits %d tx_credits %d",
1645 d, d->state, d->cfc, d->rx_credits, d->tx_credits); 1645 d, d->state, d->cfc, d->rx_credits, d->tx_credits);
1646 1646
1647 /* Send pending MSC */ 1647 /* Send pending MSC */
1648 if (test_and_clear_bit(RFCOMM_MSC_PENDING, &d->flags)) 1648 if (test_and_clear_bit(RFCOMM_MSC_PENDING, &d->flags))
1649 rfcomm_send_msc(d->session, 1, d->dlci, d->v24_sig); 1649 rfcomm_send_msc(d->session, 1, d->dlci, d->v24_sig);
1650 1650
1651 if (d->cfc) { 1651 if (d->cfc) {
1652 /* CFC enabled. 1652 /* CFC enabled.
1653 * Give them some credits */ 1653 * Give them some credits */
1654 if (!test_bit(RFCOMM_RX_THROTTLED, &d->flags) && 1654 if (!test_bit(RFCOMM_RX_THROTTLED, &d->flags) &&
1655 d->rx_credits <= (d->cfc >> 2)) { 1655 d->rx_credits <= (d->cfc >> 2)) {
1656 rfcomm_send_credits(d->session, d->addr, d->cfc - d->rx_credits); 1656 rfcomm_send_credits(d->session, d->addr, d->cfc - d->rx_credits);
1657 d->rx_credits = d->cfc; 1657 d->rx_credits = d->cfc;
1658 } 1658 }
@@ -1876,7 +1876,7 @@ static int rfcomm_add_listener(bdaddr_t *ba)
1876 1876
1877 /* Create socket */ 1877 /* Create socket */
1878 err = rfcomm_l2sock_create(&sock); 1878 err = rfcomm_l2sock_create(&sock);
1879 if (err < 0) { 1879 if (err < 0) {
1880 BT_ERR("Create socket failed %d", err); 1880 BT_ERR("Create socket failed %d", err);
1881 return err; 1881 return err;
1882 } 1882 }