Commit dcba0dba authored by Gustavo F. Padovan's avatar Gustavo F. Padovan

Bluetooth: move l2cap_sock_shutdown() to l2cap_sock.c

Declare __l2cap_wait_ack() and  l2cap_sock_clear_timer() in l2cap.h
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent 68983259
...@@ -434,8 +434,10 @@ void l2cap_cleanup_sockets(void); ...@@ -434,8 +434,10 @@ void l2cap_cleanup_sockets(void);
u8 l2cap_get_ident(struct l2cap_conn *conn); u8 l2cap_get_ident(struct l2cap_conn *conn);
void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data);
int l2cap_build_conf_req(struct sock *sk, void *data); int l2cap_build_conf_req(struct sock *sk, void *data);
int __l2cap_wait_ack(struct sock *sk);
void l2cap_sock_set_timer(struct sock *sk, long timeout); void l2cap_sock_set_timer(struct sock *sk, long timeout);
void l2cap_sock_clear_timer(struct sock *sk);
void __l2cap_sock_close(struct sock *sk, int reason); void __l2cap_sock_close(struct sock *sk, int reason);
void l2cap_sock_kill(struct sock *sk); void l2cap_sock_kill(struct sock *sk);
void l2cap_sock_init(struct sock *sk, struct sock *parent); void l2cap_sock_init(struct sock *sk, struct sock *parent);
...@@ -444,7 +446,6 @@ struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, ...@@ -444,7 +446,6 @@ struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
int l2cap_do_connect(struct sock *sk); int l2cap_do_connect(struct sock *sk);
int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len); int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len);
int l2cap_sock_shutdown(struct socket *sock, int how);
void l2cap_load(void); void l2cap_load(void);
......
...@@ -84,7 +84,7 @@ void l2cap_sock_set_timer(struct sock *sk, long timeout) ...@@ -84,7 +84,7 @@ void l2cap_sock_set_timer(struct sock *sk, long timeout)
sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout); sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout);
} }
static void l2cap_sock_clear_timer(struct sock *sk) void l2cap_sock_clear_timer(struct sock *sk)
{ {
BT_DBG("sock %p state %d", sk, sk->sk_state); BT_DBG("sock %p state %d", sk, sk->sk_state);
sk_stop_timer(sk, &sk->sk_timer); sk_stop_timer(sk, &sk->sk_timer);
...@@ -907,7 +907,7 @@ int l2cap_do_connect(struct sock *sk) ...@@ -907,7 +907,7 @@ int l2cap_do_connect(struct sock *sk)
return err; return err;
} }
static int __l2cap_wait_ack(struct sock *sk) int __l2cap_wait_ack(struct sock *sk)
{ {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
int err = 0; int err = 0;
...@@ -1468,37 +1468,6 @@ int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m ...@@ -1468,37 +1468,6 @@ int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m
return err; return err;
} }
int l2cap_sock_shutdown(struct socket *sock, int how)
{
struct sock *sk = sock->sk;
int err = 0;
BT_DBG("sock %p, sk %p", sock, sk);
if (!sk)
return 0;
lock_sock(sk);
if (!sk->sk_shutdown) {
if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM)
err = __l2cap_wait_ack(sk);
sk->sk_shutdown = SHUTDOWN_MASK;
l2cap_sock_clear_timer(sk);
__l2cap_sock_close(sk, 0);
if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
err = bt_sock_wait_state(sk, BT_CLOSED,
sk->sk_lingertime);
}
if (!err && sk->sk_err)
err = -sk->sk_err;
release_sock(sk);
return err;
}
static void l2cap_chan_ready(struct sock *sk) static void l2cap_chan_ready(struct sock *sk)
{ {
struct sock *parent = bt_sk(sk)->parent; struct sock *parent = bt_sk(sk)->parent;
......
...@@ -723,6 +723,37 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms ...@@ -723,6 +723,37 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms
return bt_sock_recvmsg(iocb, sock, msg, len, flags); return bt_sock_recvmsg(iocb, sock, msg, len, flags);
} }
static int l2cap_sock_shutdown(struct socket *sock, int how)
{
struct sock *sk = sock->sk;
int err = 0;
BT_DBG("sock %p, sk %p", sock, sk);
if (!sk)
return 0;
lock_sock(sk);
if (!sk->sk_shutdown) {
if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM)
err = __l2cap_wait_ack(sk);
sk->sk_shutdown = SHUTDOWN_MASK;
l2cap_sock_clear_timer(sk);
__l2cap_sock_close(sk, 0);
if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
err = bt_sock_wait_state(sk, BT_CLOSED,
sk->sk_lingertime);
}
if (!err && sk->sk_err)
err = -sk->sk_err;
release_sock(sk);
return err;
}
static int l2cap_sock_release(struct socket *sock) static int l2cap_sock_release(struct socket *sock)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment