diff options
author | David S. Miller <davem@davemloft.net> | 2008-07-19 03:30:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-19 03:30:39 -0400 |
commit | 407d819cf0fd54c6fc1138a509225696aecafd15 (patch) | |
tree | b653a5c8c09f7c316f5f98947be262e27a4ca33a /net/bluetooth/rfcomm | |
parent | 7abbcd6a4c8d6179121f2915a761b1133bf1cd99 (diff) | |
parent | b1235d79611e78a07629b4cbe53291c9cffd1834 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/holtmann/bluetooth-2.6
Diffstat (limited to 'net/bluetooth/rfcomm')
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 92 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 23 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/tty.c | 59 |
3 files changed, 134 insertions, 40 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index b4fb84e398e5..6cfc7ba611b3 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -51,7 +51,7 @@ | |||
51 | #define BT_DBG(D...) | 51 | #define BT_DBG(D...) |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #define VERSION "1.8" | 54 | #define VERSION "1.10" |
55 | 55 | ||
56 | static int disable_cfc = 0; | 56 | static int disable_cfc = 0; |
57 | static int channel_mtu = -1; | 57 | static int channel_mtu = -1; |
@@ -228,6 +228,21 @@ static int rfcomm_l2sock_create(struct socket **sock) | |||
228 | return err; | 228 | return err; |
229 | } | 229 | } |
230 | 230 | ||
231 | static inline int rfcomm_check_link_mode(struct rfcomm_dlc *d) | ||
232 | { | ||
233 | struct sock *sk = d->session->sock->sk; | ||
234 | |||
235 | if (d->link_mode & (RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE)) { | ||
236 | if (!hci_conn_encrypt(l2cap_pi(sk)->conn->hcon)) | ||
237 | return 1; | ||
238 | } else if (d->link_mode & RFCOMM_LM_AUTH) { | ||
239 | if (!hci_conn_auth(l2cap_pi(sk)->conn->hcon)) | ||
240 | return 1; | ||
241 | } | ||
242 | |||
243 | return 0; | ||
244 | } | ||
245 | |||
231 | /* ---- RFCOMM DLCs ---- */ | 246 | /* ---- RFCOMM DLCs ---- */ |
232 | static void rfcomm_dlc_timeout(unsigned long arg) | 247 | static void rfcomm_dlc_timeout(unsigned long arg) |
233 | { | 248 | { |
@@ -369,15 +384,23 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, | |||
369 | d->addr = __addr(s->initiator, dlci); | 384 | d->addr = __addr(s->initiator, dlci); |
370 | d->priority = 7; | 385 | d->priority = 7; |
371 | 386 | ||
372 | d->state = BT_CONFIG; | 387 | d->state = BT_CONFIG; |
373 | rfcomm_dlc_link(s, d); | 388 | rfcomm_dlc_link(s, d); |
374 | 389 | ||
390 | d->out = 1; | ||
391 | |||
375 | d->mtu = s->mtu; | 392 | d->mtu = s->mtu; |
376 | d->cfc = (s->cfc == RFCOMM_CFC_UNKNOWN) ? 0 : s->cfc; | 393 | d->cfc = (s->cfc == RFCOMM_CFC_UNKNOWN) ? 0 : s->cfc; |
377 | 394 | ||
378 | if (s->state == BT_CONNECTED) | 395 | if (s->state == BT_CONNECTED) { |
379 | rfcomm_send_pn(s, 1, d); | 396 | if (rfcomm_check_link_mode(d)) |
397 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); | ||
398 | else | ||
399 | rfcomm_send_pn(s, 1, d); | ||
400 | } | ||
401 | |||
380 | rfcomm_dlc_set_timer(d, RFCOMM_CONN_TIMEOUT); | 402 | rfcomm_dlc_set_timer(d, RFCOMM_CONN_TIMEOUT); |
403 | |||
381 | return 0; | 404 | return 0; |
382 | } | 405 | } |
383 | 406 | ||
@@ -1144,21 +1167,6 @@ static int rfcomm_recv_disc(struct rfcomm_session *s, u8 dlci) | |||
1144 | return 0; | 1167 | return 0; |
1145 | } | 1168 | } |
1146 | 1169 | ||
1147 | static inline int rfcomm_check_link_mode(struct rfcomm_dlc *d) | ||
1148 | { | ||
1149 | struct sock *sk = d->session->sock->sk; | ||
1150 | |||
1151 | if (d->link_mode & (RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE)) { | ||
1152 | if (!hci_conn_encrypt(l2cap_pi(sk)->conn->hcon)) | ||
1153 | return 1; | ||
1154 | } else if (d->link_mode & RFCOMM_LM_AUTH) { | ||
1155 | if (!hci_conn_auth(l2cap_pi(sk)->conn->hcon)) | ||
1156 | return 1; | ||
1157 | } | ||
1158 | |||
1159 | return 0; | ||
1160 | } | ||
1161 | |||
1162 | static void rfcomm_dlc_accept(struct rfcomm_dlc *d) | 1170 | static void rfcomm_dlc_accept(struct rfcomm_dlc *d) |
1163 | { | 1171 | { |
1164 | struct sock *sk = d->session->sock->sk; | 1172 | struct sock *sk = d->session->sock->sk; |
@@ -1203,10 +1211,8 @@ static int rfcomm_recv_sabm(struct rfcomm_session *s, u8 dlci) | |||
1203 | if (rfcomm_check_link_mode(d)) { | 1211 | if (rfcomm_check_link_mode(d)) { |
1204 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); | 1212 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); |
1205 | rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); | 1213 | rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); |
1206 | return 0; | 1214 | } else |
1207 | } | 1215 | rfcomm_dlc_accept(d); |
1208 | |||
1209 | rfcomm_dlc_accept(d); | ||
1210 | } | 1216 | } |
1211 | return 0; | 1217 | return 0; |
1212 | } | 1218 | } |
@@ -1221,10 +1227,8 @@ static int rfcomm_recv_sabm(struct rfcomm_session *s, u8 dlci) | |||
1221 | if (rfcomm_check_link_mode(d)) { | 1227 | if (rfcomm_check_link_mode(d)) { |
1222 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); | 1228 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); |
1223 | rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); | 1229 | rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); |
1224 | return 0; | 1230 | } else |
1225 | } | 1231 | rfcomm_dlc_accept(d); |
1226 | |||
1227 | rfcomm_dlc_accept(d); | ||
1228 | } else { | 1232 | } else { |
1229 | rfcomm_send_dm(s, dlci); | 1233 | rfcomm_send_dm(s, dlci); |
1230 | } | 1234 | } |
@@ -1457,8 +1461,12 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb | |||
1457 | clear_bit(RFCOMM_TX_THROTTLED, &d->flags); | 1461 | clear_bit(RFCOMM_TX_THROTTLED, &d->flags); |
1458 | 1462 | ||
1459 | rfcomm_dlc_lock(d); | 1463 | rfcomm_dlc_lock(d); |
1464 | |||
1465 | d->remote_v24_sig = msc->v24_sig; | ||
1466 | |||
1460 | if (d->modem_status) | 1467 | if (d->modem_status) |
1461 | d->modem_status(d, msc->v24_sig); | 1468 | d->modem_status(d, msc->v24_sig); |
1469 | |||
1462 | rfcomm_dlc_unlock(d); | 1470 | rfcomm_dlc_unlock(d); |
1463 | 1471 | ||
1464 | rfcomm_send_msc(s, 0, dlci, msc->v24_sig); | 1472 | rfcomm_send_msc(s, 0, dlci, msc->v24_sig); |
@@ -1634,7 +1642,11 @@ static void rfcomm_process_connect(struct rfcomm_session *s) | |||
1634 | d = list_entry(p, struct rfcomm_dlc, list); | 1642 | d = list_entry(p, struct rfcomm_dlc, list); |
1635 | if (d->state == BT_CONFIG) { | 1643 | if (d->state == BT_CONFIG) { |
1636 | d->mtu = s->mtu; | 1644 | d->mtu = s->mtu; |
1637 | rfcomm_send_pn(s, 1, d); | 1645 | if (rfcomm_check_link_mode(d)) { |
1646 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); | ||
1647 | rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); | ||
1648 | } else | ||
1649 | rfcomm_send_pn(s, 1, d); | ||
1638 | } | 1650 | } |
1639 | } | 1651 | } |
1640 | } | 1652 | } |
@@ -1707,7 +1719,11 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s) | |||
1707 | 1719 | ||
1708 | if (test_and_clear_bit(RFCOMM_AUTH_ACCEPT, &d->flags)) { | 1720 | if (test_and_clear_bit(RFCOMM_AUTH_ACCEPT, &d->flags)) { |
1709 | rfcomm_dlc_clear_timer(d); | 1721 | rfcomm_dlc_clear_timer(d); |
1710 | rfcomm_dlc_accept(d); | 1722 | if (d->out) { |
1723 | rfcomm_send_pn(s, 1, d); | ||
1724 | rfcomm_dlc_set_timer(d, RFCOMM_CONN_TIMEOUT); | ||
1725 | } else | ||
1726 | rfcomm_dlc_accept(d); | ||
1711 | if (d->link_mode & RFCOMM_LM_SECURE) { | 1727 | if (d->link_mode & RFCOMM_LM_SECURE) { |
1712 | struct sock *sk = s->sock->sk; | 1728 | struct sock *sk = s->sock->sk; |
1713 | hci_conn_change_link_key(l2cap_pi(sk)->conn->hcon); | 1729 | hci_conn_change_link_key(l2cap_pi(sk)->conn->hcon); |
@@ -1715,7 +1731,10 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s) | |||
1715 | continue; | 1731 | continue; |
1716 | } else if (test_and_clear_bit(RFCOMM_AUTH_REJECT, &d->flags)) { | 1732 | } else if (test_and_clear_bit(RFCOMM_AUTH_REJECT, &d->flags)) { |
1717 | rfcomm_dlc_clear_timer(d); | 1733 | rfcomm_dlc_clear_timer(d); |
1718 | rfcomm_send_dm(s, d->dlci); | 1734 | if (!d->out) |
1735 | rfcomm_send_dm(s, d->dlci); | ||
1736 | else | ||
1737 | d->state = BT_CLOSED; | ||
1719 | __rfcomm_dlc_close(d, ECONNREFUSED); | 1738 | __rfcomm_dlc_close(d, ECONNREFUSED); |
1720 | continue; | 1739 | continue; |
1721 | } | 1740 | } |
@@ -1724,7 +1743,7 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s) | |||
1724 | continue; | 1743 | continue; |
1725 | 1744 | ||
1726 | if ((d->state == BT_CONNECTED || d->state == BT_DISCONN) && | 1745 | if ((d->state == BT_CONNECTED || d->state == BT_DISCONN) && |
1727 | d->mscex == RFCOMM_MSCEX_OK) | 1746 | d->mscex == RFCOMM_MSCEX_OK) |
1728 | rfcomm_process_tx(d); | 1747 | rfcomm_process_tx(d); |
1729 | } | 1748 | } |
1730 | } | 1749 | } |
@@ -1952,7 +1971,8 @@ static void rfcomm_auth_cfm(struct hci_conn *conn, u8 status) | |||
1952 | list_for_each_safe(p, n, &s->dlcs) { | 1971 | list_for_each_safe(p, n, &s->dlcs) { |
1953 | d = list_entry(p, struct rfcomm_dlc, list); | 1972 | d = list_entry(p, struct rfcomm_dlc, list); |
1954 | 1973 | ||
1955 | if (d->link_mode & (RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE)) | 1974 | if ((d->link_mode & (RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE)) && |
1975 | !(conn->link_mode & HCI_LM_ENCRYPT) && !status) | ||
1956 | continue; | 1976 | continue; |
1957 | 1977 | ||
1958 | if (!test_and_clear_bit(RFCOMM_AUTH_PENDING, &d->flags)) | 1978 | if (!test_and_clear_bit(RFCOMM_AUTH_PENDING, &d->flags)) |
@@ -1986,6 +2006,14 @@ static void rfcomm_encrypt_cfm(struct hci_conn *conn, u8 status, u8 encrypt) | |||
1986 | list_for_each_safe(p, n, &s->dlcs) { | 2006 | list_for_each_safe(p, n, &s->dlcs) { |
1987 | d = list_entry(p, struct rfcomm_dlc, list); | 2007 | d = list_entry(p, struct rfcomm_dlc, list); |
1988 | 2008 | ||
2009 | if ((d->link_mode & (RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE)) && | ||
2010 | (d->state == BT_CONNECTED || | ||
2011 | d->state == BT_CONFIG) && | ||
2012 | !status && encrypt == 0x00) { | ||
2013 | __rfcomm_dlc_close(d, ECONNREFUSED); | ||
2014 | continue; | ||
2015 | } | ||
2016 | |||
1989 | if (!test_and_clear_bit(RFCOMM_AUTH_PENDING, &d->flags)) | 2017 | if (!test_and_clear_bit(RFCOMM_AUTH_PENDING, &d->flags)) |
1990 | continue; | 2018 | continue; |
1991 | 2019 | ||
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index c9054487670a..8a972b6ba85f 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -307,13 +307,13 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int | |||
307 | sk->sk_destruct = rfcomm_sock_destruct; | 307 | sk->sk_destruct = rfcomm_sock_destruct; |
308 | sk->sk_sndtimeo = RFCOMM_CONN_TIMEOUT; | 308 | sk->sk_sndtimeo = RFCOMM_CONN_TIMEOUT; |
309 | 309 | ||
310 | sk->sk_sndbuf = RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10; | 310 | sk->sk_sndbuf = RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10; |
311 | sk->sk_rcvbuf = RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10; | 311 | sk->sk_rcvbuf = RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10; |
312 | 312 | ||
313 | sock_reset_flag(sk, SOCK_ZAPPED); | 313 | sock_reset_flag(sk, SOCK_ZAPPED); |
314 | 314 | ||
315 | sk->sk_protocol = proto; | 315 | sk->sk_protocol = proto; |
316 | sk->sk_state = BT_OPEN; | 316 | sk->sk_state = BT_OPEN; |
317 | 317 | ||
318 | bt_sock_link(&rfcomm_sk_list, sk); | 318 | bt_sock_link(&rfcomm_sk_list, sk); |
319 | 319 | ||
@@ -411,6 +411,8 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a | |||
411 | bacpy(&bt_sk(sk)->dst, &sa->rc_bdaddr); | 411 | bacpy(&bt_sk(sk)->dst, &sa->rc_bdaddr); |
412 | rfcomm_pi(sk)->channel = sa->rc_channel; | 412 | rfcomm_pi(sk)->channel = sa->rc_channel; |
413 | 413 | ||
414 | d->link_mode = rfcomm_pi(sk)->link_mode; | ||
415 | |||
414 | err = rfcomm_dlc_open(d, &bt_sk(sk)->src, &sa->rc_bdaddr, sa->rc_channel); | 416 | err = rfcomm_dlc_open(d, &bt_sk(sk)->src, &sa->rc_bdaddr, sa->rc_channel); |
415 | if (!err) | 417 | if (!err) |
416 | err = bt_sock_wait_state(sk, BT_CONNECTED, | 418 | err = bt_sock_wait_state(sk, BT_CONNECTED, |
@@ -686,6 +688,8 @@ static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
686 | copied += chunk; | 688 | copied += chunk; |
687 | size -= chunk; | 689 | size -= chunk; |
688 | 690 | ||
691 | sock_recv_timestamp(msg, sk, skb); | ||
692 | |||
689 | if (!(flags & MSG_PEEK)) { | 693 | if (!(flags & MSG_PEEK)) { |
690 | atomic_sub(chunk, &sk->sk_rmem_alloc); | 694 | atomic_sub(chunk, &sk->sk_rmem_alloc); |
691 | 695 | ||
@@ -791,15 +795,20 @@ static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned lon | |||
791 | struct sock *sk = sock->sk; | 795 | struct sock *sk = sock->sk; |
792 | int err; | 796 | int err; |
793 | 797 | ||
794 | lock_sock(sk); | 798 | BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg); |
799 | |||
800 | err = bt_sock_ioctl(sock, cmd, arg); | ||
795 | 801 | ||
802 | if (err == -ENOIOCTLCMD) { | ||
796 | #ifdef CONFIG_BT_RFCOMM_TTY | 803 | #ifdef CONFIG_BT_RFCOMM_TTY |
797 | err = rfcomm_dev_ioctl(sk, cmd, (void __user *)arg); | 804 | lock_sock(sk); |
805 | err = rfcomm_dev_ioctl(sk, cmd, (void __user *) arg); | ||
806 | release_sock(sk); | ||
798 | #else | 807 | #else |
799 | err = -EOPNOTSUPP; | 808 | err = -EOPNOTSUPP; |
800 | #endif | 809 | #endif |
810 | } | ||
801 | 811 | ||
802 | release_sock(sk); | ||
803 | return err; | 812 | return err; |
804 | } | 813 | } |
805 | 814 | ||
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index be84f4fc1477..5d163571d3f7 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c | |||
@@ -75,6 +75,8 @@ struct rfcomm_dev { | |||
75 | struct device *tty_dev; | 75 | struct device *tty_dev; |
76 | 76 | ||
77 | atomic_t wmem_alloc; | 77 | atomic_t wmem_alloc; |
78 | |||
79 | struct sk_buff_head pending; | ||
78 | }; | 80 | }; |
79 | 81 | ||
80 | static LIST_HEAD(rfcomm_dev_list); | 82 | static LIST_HEAD(rfcomm_dev_list); |
@@ -262,13 +264,34 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) | |||
262 | init_waitqueue_head(&dev->wait); | 264 | init_waitqueue_head(&dev->wait); |
263 | tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev); | 265 | tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev); |
264 | 266 | ||
267 | skb_queue_head_init(&dev->pending); | ||
268 | |||
265 | rfcomm_dlc_lock(dlc); | 269 | rfcomm_dlc_lock(dlc); |
270 | |||
271 | if (req->flags & (1 << RFCOMM_REUSE_DLC)) { | ||
272 | struct sock *sk = dlc->owner; | ||
273 | struct sk_buff *skb; | ||
274 | |||
275 | BUG_ON(!sk); | ||
276 | |||
277 | rfcomm_dlc_throttle(dlc); | ||
278 | |||
279 | while ((skb = skb_dequeue(&sk->sk_receive_queue))) { | ||
280 | skb_orphan(skb); | ||
281 | skb_queue_tail(&dev->pending, skb); | ||
282 | atomic_sub(skb->len, &sk->sk_rmem_alloc); | ||
283 | } | ||
284 | } | ||
285 | |||
266 | dlc->data_ready = rfcomm_dev_data_ready; | 286 | dlc->data_ready = rfcomm_dev_data_ready; |
267 | dlc->state_change = rfcomm_dev_state_change; | 287 | dlc->state_change = rfcomm_dev_state_change; |
268 | dlc->modem_status = rfcomm_dev_modem_status; | 288 | dlc->modem_status = rfcomm_dev_modem_status; |
269 | 289 | ||
270 | dlc->owner = dev; | 290 | dlc->owner = dev; |
271 | dev->dlc = dlc; | 291 | dev->dlc = dlc; |
292 | |||
293 | rfcomm_dev_modem_status(dlc, dlc->remote_v24_sig); | ||
294 | |||
272 | rfcomm_dlc_unlock(dlc); | 295 | rfcomm_dlc_unlock(dlc); |
273 | 296 | ||
274 | /* It's safe to call __module_get() here because socket already | 297 | /* It's safe to call __module_get() here because socket already |
@@ -537,11 +560,16 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) | |||
537 | struct rfcomm_dev *dev = dlc->owner; | 560 | struct rfcomm_dev *dev = dlc->owner; |
538 | struct tty_struct *tty; | 561 | struct tty_struct *tty; |
539 | 562 | ||
540 | if (!dev || !(tty = dev->tty)) { | 563 | if (!dev) { |
541 | kfree_skb(skb); | 564 | kfree_skb(skb); |
542 | return; | 565 | return; |
543 | } | 566 | } |
544 | 567 | ||
568 | if (!(tty = dev->tty) || !skb_queue_empty(&dev->pending)) { | ||
569 | skb_queue_tail(&dev->pending, skb); | ||
570 | return; | ||
571 | } | ||
572 | |||
545 | BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); | 573 | BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); |
546 | 574 | ||
547 | tty_insert_flip_string(tty, skb->data, skb->len); | 575 | tty_insert_flip_string(tty, skb->data, skb->len); |
@@ -625,6 +653,30 @@ static void rfcomm_tty_wakeup(unsigned long arg) | |||
625 | #endif | 653 | #endif |
626 | } | 654 | } |
627 | 655 | ||
656 | static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) | ||
657 | { | ||
658 | struct tty_struct *tty = dev->tty; | ||
659 | struct sk_buff *skb; | ||
660 | int inserted = 0; | ||
661 | |||
662 | if (!tty) | ||
663 | return; | ||
664 | |||
665 | BT_DBG("dev %p tty %p", dev, tty); | ||
666 | |||
667 | rfcomm_dlc_lock(dev->dlc); | ||
668 | |||
669 | while ((skb = skb_dequeue(&dev->pending))) { | ||
670 | inserted += tty_insert_flip_string(tty, skb->data, skb->len); | ||
671 | kfree_skb(skb); | ||
672 | } | ||
673 | |||
674 | rfcomm_dlc_unlock(dev->dlc); | ||
675 | |||
676 | if (inserted > 0) | ||
677 | tty_flip_buffer_push(tty); | ||
678 | } | ||
679 | |||
628 | static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) | 680 | static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) |
629 | { | 681 | { |
630 | DECLARE_WAITQUEUE(wait, current); | 682 | DECLARE_WAITQUEUE(wait, current); |
@@ -689,6 +741,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) | |||
689 | if (err == 0) | 741 | if (err == 0) |
690 | device_move(dev->tty_dev, rfcomm_get_device(dev)); | 742 | device_move(dev->tty_dev, rfcomm_get_device(dev)); |
691 | 743 | ||
744 | rfcomm_tty_copy_pending(dev); | ||
745 | |||
746 | rfcomm_dlc_unthrottle(dev->dlc); | ||
747 | |||
692 | return err; | 748 | return err; |
693 | } | 749 | } |
694 | 750 | ||
@@ -1121,6 +1177,7 @@ int rfcomm_init_ttys(void) | |||
1121 | rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; | 1177 | rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; |
1122 | rfcomm_tty_driver->init_termios = tty_std_termios; | 1178 | rfcomm_tty_driver->init_termios = tty_std_termios; |
1123 | rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | 1179 | rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; |
1180 | rfcomm_tty_driver->init_termios.c_lflag &= ~ICANON; | ||
1124 | tty_set_operations(rfcomm_tty_driver, &rfcomm_ops); | 1181 | tty_set_operations(rfcomm_tty_driver, &rfcomm_ops); |
1125 | 1182 | ||
1126 | if (tty_register_driver(rfcomm_tty_driver)) { | 1183 | if (tty_register_driver(rfcomm_tty_driver)) { |