diff options
| author | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2013-10-15 18:24:49 -0400 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2013-10-15 19:42:44 -0400 |
| commit | dc25306b033cc27ca2a45b4bb307a437092408d1 (patch) | |
| tree | bf5794e0605990efeb48b5241f3dee81ab713c07 | |
| parent | 5ec1bbe549d939ff1ef88e2cc22b2c3b95d76401 (diff) | |
Bluetooth: Move l2cap_wait_ack() to l2cap_sock.c
The wait_ack code has a heavy dependency on the socket data structures
and, as of now, it won't be worthless change it to use non-socket
structures as the only user of such feature is a socket.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
| -rw-r--r-- | include/net/bluetooth/l2cap.h | 1 | ||||
| -rw-r--r-- | net/bluetooth/l2cap_core.c | 32 | ||||
| -rw-r--r-- | net/bluetooth/l2cap_sock.c | 32 |
3 files changed, 32 insertions, 33 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index ae3a99bc31d0..377db2aa89f9 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
| @@ -813,7 +813,6 @@ void l2cap_cleanup_sockets(void); | |||
| 813 | bool l2cap_is_socket(struct socket *sock); | 813 | bool l2cap_is_socket(struct socket *sock); |
| 814 | 814 | ||
| 815 | void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); | 815 | void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); |
| 816 | int __l2cap_wait_ack(struct sock *sk); | ||
| 817 | 816 | ||
| 818 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); | 817 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); |
| 819 | int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); | 818 | int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 634781a60d3f..39f02c08a882 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
| @@ -1894,38 +1894,6 @@ done: | |||
| 1894 | return err; | 1894 | return err; |
| 1895 | } | 1895 | } |
| 1896 | 1896 | ||
| 1897 | int __l2cap_wait_ack(struct sock *sk) | ||
| 1898 | { | ||
| 1899 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | ||
| 1900 | DECLARE_WAITQUEUE(wait, current); | ||
| 1901 | int err = 0; | ||
| 1902 | int timeo = HZ/5; | ||
| 1903 | |||
| 1904 | add_wait_queue(sk_sleep(sk), &wait); | ||
| 1905 | set_current_state(TASK_INTERRUPTIBLE); | ||
| 1906 | while (chan->unacked_frames > 0 && chan->conn) { | ||
| 1907 | if (!timeo) | ||
| 1908 | timeo = HZ/5; | ||
| 1909 | |||
| 1910 | if (signal_pending(current)) { | ||
| 1911 | err = sock_intr_errno(timeo); | ||
| 1912 | break; | ||
| 1913 | } | ||
| 1914 | |||
| 1915 | release_sock(sk); | ||
| 1916 | timeo = schedule_timeout(timeo); | ||
| 1917 | lock_sock(sk); | ||
| 1918 | set_current_state(TASK_INTERRUPTIBLE); | ||
| 1919 | |||
| 1920 | err = sock_error(sk); | ||
| 1921 | if (err) | ||
| 1922 | break; | ||
| 1923 | } | ||
| 1924 | set_current_state(TASK_RUNNING); | ||
| 1925 | remove_wait_queue(sk_sleep(sk), &wait); | ||
| 1926 | return err; | ||
| 1927 | } | ||
| 1928 | |||
| 1929 | static void l2cap_monitor_timeout(struct work_struct *work) | 1897 | static void l2cap_monitor_timeout(struct work_struct *work) |
| 1930 | { | 1898 | { |
| 1931 | struct l2cap_chan *chan = container_of(work, struct l2cap_chan, | 1899 | struct l2cap_chan *chan = container_of(work, struct l2cap_chan, |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 301f25b9b521..68f486a586ff 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
| @@ -879,6 +879,38 @@ static void l2cap_sock_kill(struct sock *sk) | |||
| 879 | sock_put(sk); | 879 | sock_put(sk); |
| 880 | } | 880 | } |
| 881 | 881 | ||
| 882 | static int __l2cap_wait_ack(struct sock *sk) | ||
| 883 | { | ||
| 884 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | ||
| 885 | DECLARE_WAITQUEUE(wait, current); | ||
| 886 | int err = 0; | ||
| 887 | int timeo = HZ/5; | ||
| 888 | |||
| 889 | add_wait_queue(sk_sleep(sk), &wait); | ||
| 890 | set_current_state(TASK_INTERRUPTIBLE); | ||
| 891 | while (chan->unacked_frames > 0 && chan->conn) { | ||
| 892 | if (!timeo) | ||
| 893 | timeo = HZ/5; | ||
| 894 | |||
| 895 | if (signal_pending(current)) { | ||
| 896 | err = sock_intr_errno(timeo); | ||
| 897 | break; | ||
| 898 | } | ||
| 899 | |||
| 900 | release_sock(sk); | ||
| 901 | timeo = schedule_timeout(timeo); | ||
| 902 | lock_sock(sk); | ||
| 903 | set_current_state(TASK_INTERRUPTIBLE); | ||
| 904 | |||
| 905 | err = sock_error(sk); | ||
| 906 | if (err) | ||
| 907 | break; | ||
| 908 | } | ||
| 909 | set_current_state(TASK_RUNNING); | ||
| 910 | remove_wait_queue(sk_sleep(sk), &wait); | ||
| 911 | return err; | ||
| 912 | } | ||
| 913 | |||
| 882 | static int l2cap_sock_shutdown(struct socket *sock, int how) | 914 | static int l2cap_sock_shutdown(struct socket *sock, int how) |
| 883 | { | 915 | { |
| 884 | struct sock *sk = sock->sk; | 916 | struct sock *sk = sock->sk; |
