mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 23:21:46 +00:00
Bluetooth: Merge l2cap_chan_create() in the l2cap_sock_alloc()
As a first step to remove l2cap_sock_alloc() and l2cap_sock_init() from l2cap_core.c Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
This commit is contained in:
parent
448f2627c1
commit
dc50a06dac
2 changed files with 12 additions and 24 deletions
|
@ -853,6 +853,7 @@ static struct proto l2cap_proto = {
|
|||
struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio)
|
||||
{
|
||||
struct sock *sk;
|
||||
struct l2cap_chan *chan;
|
||||
|
||||
sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto);
|
||||
if (!sk)
|
||||
|
@ -869,6 +870,14 @@ struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, g
|
|||
sk->sk_protocol = proto;
|
||||
sk->sk_state = BT_OPEN;
|
||||
|
||||
chan = l2cap_chan_create(sk);
|
||||
if (!chan) {
|
||||
l2cap_sock_kill(sk);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
l2cap_pi(sk)->chan = chan;
|
||||
|
||||
return sk;
|
||||
}
|
||||
|
||||
|
@ -876,7 +885,6 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,
|
|||
int kern)
|
||||
{
|
||||
struct sock *sk;
|
||||
struct l2cap_chan *chan;
|
||||
|
||||
BT_DBG("sock %p", sock);
|
||||
|
||||
|
@ -895,14 +903,6 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,
|
|||
if (!sk)
|
||||
return -ENOMEM;
|
||||
|
||||
chan = l2cap_chan_create(sk);
|
||||
if (!chan) {
|
||||
l2cap_sock_kill(sk);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
l2cap_pi(sk)->chan = chan;
|
||||
|
||||
l2cap_sock_init(sk, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue