Skip to content

Commit dc25306

Browse files
Gustavo Padovanholtmann
authored andcommitted
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>
1 parent 5ec1bbe commit dc25306

3 files changed

Lines changed: 32 additions & 33 deletions

File tree

‎include/net/bluetooth/l2cap.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,6 @@ void l2cap_cleanup_sockets(void);
813813
bool l2cap_is_socket(struct socket *sock);
814814

815815
void __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
816-
int __l2cap_wait_ack(struct sock *sk);
817816

818817
int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
819818
int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid);

‎net/bluetooth/l2cap_core.c‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,38 +1894,6 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
18941894
return err;
18951895
}
18961896

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-
19291897
static void l2cap_monitor_timeout(struct work_struct *work)
19301898
{
19311899
struct l2cap_chan *chan = container_of(work, struct l2cap_chan,

‎net/bluetooth/l2cap_sock.c‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,38 @@ static void l2cap_sock_kill(struct sock *sk)
879879
sock_put(sk);
880880
}
881881

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+
882914
static int l2cap_sock_shutdown(struct socket *sock, int how)
883915
{
884916
struct sock *sk = sock->sk;

0 commit comments

Comments
 (0)