diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-02-04 00:08:36 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-02-07 22:43:31 -0500 |
commit | dcba0dba54b566a08376f93cab35cdabd6abda20 (patch) | |
tree | b56d1c1694723e2e7c138cfa763c885b6c14eda2 /net/bluetooth | |
parent | 6898325923f9571fbede3372dc490faa43b3258a (diff) |
Bluetooth: move l2cap_sock_shutdown() to l2cap_sock.c
Declare __l2cap_wait_ack() and l2cap_sock_clear_timer() in l2cap.h
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/l2cap_core.c | 35 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 31 |
2 files changed, 33 insertions, 33 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 3a0e42be89ea..6e48e580555e 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -84,7 +84,7 @@ void l2cap_sock_set_timer(struct sock *sk, long timeout) | |||
84 | sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout); | 84 | sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout); |
85 | } | 85 | } |
86 | 86 | ||
87 | static void l2cap_sock_clear_timer(struct sock *sk) | 87 | void l2cap_sock_clear_timer(struct sock *sk) |
88 | { | 88 | { |
89 | BT_DBG("sock %p state %d", sk, sk->sk_state); | 89 | BT_DBG("sock %p state %d", sk, sk->sk_state); |
90 | sk_stop_timer(sk, &sk->sk_timer); | 90 | sk_stop_timer(sk, &sk->sk_timer); |
@@ -907,7 +907,7 @@ done: | |||
907 | return err; | 907 | return err; |
908 | } | 908 | } |
909 | 909 | ||
910 | static int __l2cap_wait_ack(struct sock *sk) | 910 | int __l2cap_wait_ack(struct sock *sk) |
911 | { | 911 | { |
912 | DECLARE_WAITQUEUE(wait, current); | 912 | DECLARE_WAITQUEUE(wait, current); |
913 | int err = 0; | 913 | int err = 0; |
@@ -1468,37 +1468,6 @@ done: | |||
1468 | return err; | 1468 | return err; |
1469 | } | 1469 | } |
1470 | 1470 | ||
1471 | int l2cap_sock_shutdown(struct socket *sock, int how) | ||
1472 | { | ||
1473 | struct sock *sk = sock->sk; | ||
1474 | int err = 0; | ||
1475 | |||
1476 | BT_DBG("sock %p, sk %p", sock, sk); | ||
1477 | |||
1478 | if (!sk) | ||
1479 | return 0; | ||
1480 | |||
1481 | lock_sock(sk); | ||
1482 | if (!sk->sk_shutdown) { | ||
1483 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) | ||
1484 | err = __l2cap_wait_ack(sk); | ||
1485 | |||
1486 | sk->sk_shutdown = SHUTDOWN_MASK; | ||
1487 | l2cap_sock_clear_timer(sk); | ||
1488 | __l2cap_sock_close(sk, 0); | ||
1489 | |||
1490 | if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) | ||
1491 | err = bt_sock_wait_state(sk, BT_CLOSED, | ||
1492 | sk->sk_lingertime); | ||
1493 | } | ||
1494 | |||
1495 | if (!err && sk->sk_err) | ||
1496 | err = -sk->sk_err; | ||
1497 | |||
1498 | release_sock(sk); | ||
1499 | return err; | ||
1500 | } | ||
1501 | |||
1502 | static void l2cap_chan_ready(struct sock *sk) | 1471 | static void l2cap_chan_ready(struct sock *sk) |
1503 | { | 1472 | { |
1504 | struct sock *parent = bt_sk(sk)->parent; | 1473 | struct sock *parent = bt_sk(sk)->parent; |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index fa2bc5d85560..93af233bb167 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -723,6 +723,37 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
723 | return bt_sock_recvmsg(iocb, sock, msg, len, flags); | 723 | return bt_sock_recvmsg(iocb, sock, msg, len, flags); |
724 | } | 724 | } |
725 | 725 | ||
726 | static int l2cap_sock_shutdown(struct socket *sock, int how) | ||
727 | { | ||
728 | struct sock *sk = sock->sk; | ||
729 | int err = 0; | ||
730 | |||
731 | BT_DBG("sock %p, sk %p", sock, sk); | ||
732 | |||
733 | if (!sk) | ||
734 | return 0; | ||
735 | |||
736 | lock_sock(sk); | ||
737 | if (!sk->sk_shutdown) { | ||
738 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) | ||
739 | err = __l2cap_wait_ack(sk); | ||
740 | |||
741 | sk->sk_shutdown = SHUTDOWN_MASK; | ||
742 | l2cap_sock_clear_timer(sk); | ||
743 | __l2cap_sock_close(sk, 0); | ||
744 | |||
745 | if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) | ||
746 | err = bt_sock_wait_state(sk, BT_CLOSED, | ||
747 | sk->sk_lingertime); | ||
748 | } | ||
749 | |||
750 | if (!err && sk->sk_err) | ||
751 | err = -sk->sk_err; | ||
752 | |||
753 | release_sock(sk); | ||
754 | return err; | ||
755 | } | ||
756 | |||
726 | static int l2cap_sock_release(struct socket *sock) | 757 | static int l2cap_sock_release(struct socket *sock) |
727 | { | 758 | { |
728 | struct sock *sk = sock->sk; | 759 | struct sock *sk = sock->sk; |