diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-05-16 15:42:01 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-06-13 13:55:32 -0400 |
commit | dc50a06dac61d7ca7ddb3d9bb8921ca5d68f51b6 (patch) | |
tree | 04719c902449041d0fe8628559e420460481c18e /net/bluetooth | |
parent | 448f2627c169092d2091a1be22feb6a7775f6201 (diff) |
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>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/l2cap_core.c | 18 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 18 |
2 files changed, 12 insertions, 24 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index dff9d76fe790..49f890bce312 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -846,13 +846,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) | |||
846 | if (!sk) | 846 | if (!sk) |
847 | goto clean; | 847 | goto clean; |
848 | 848 | ||
849 | chan = l2cap_chan_create(sk); | 849 | chan = l2cap_pi(sk)->chan; |
850 | if (!chan) { | ||
851 | l2cap_sock_kill(sk); | ||
852 | goto clean; | ||
853 | } | ||
854 | |||
855 | l2cap_pi(sk)->chan = chan; | ||
856 | 850 | ||
857 | write_lock_bh(&conn->chan_lock); | 851 | write_lock_bh(&conn->chan_lock); |
858 | 852 | ||
@@ -2339,14 +2333,6 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
2339 | if (!sk) | 2333 | if (!sk) |
2340 | goto response; | 2334 | goto response; |
2341 | 2335 | ||
2342 | chan = l2cap_chan_create(sk); | ||
2343 | if (!chan) { | ||
2344 | l2cap_sock_kill(sk); | ||
2345 | goto response; | ||
2346 | } | ||
2347 | |||
2348 | l2cap_pi(sk)->chan = chan; | ||
2349 | |||
2350 | write_lock_bh(&conn->chan_lock); | 2336 | write_lock_bh(&conn->chan_lock); |
2351 | 2337 | ||
2352 | /* Check if we already have channel with that dcid */ | 2338 | /* Check if we already have channel with that dcid */ |
@@ -2359,6 +2345,8 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
2359 | 2345 | ||
2360 | hci_conn_hold(conn->hcon); | 2346 | hci_conn_hold(conn->hcon); |
2361 | 2347 | ||
2348 | chan = l2cap_pi(sk)->chan; | ||
2349 | |||
2362 | l2cap_sock_init(sk, parent); | 2350 | l2cap_sock_init(sk, parent); |
2363 | bacpy(&bt_sk(sk)->src, conn->src); | 2351 | bacpy(&bt_sk(sk)->src, conn->src); |
2364 | bacpy(&bt_sk(sk)->dst, conn->dst); | 2352 | bacpy(&bt_sk(sk)->dst, conn->dst); |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index ab81894c6677..2f4fd5751a46 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -853,6 +853,7 @@ static struct proto l2cap_proto = { | |||
853 | struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio) | 853 | struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio) |
854 | { | 854 | { |
855 | struct sock *sk; | 855 | struct sock *sk; |
856 | struct l2cap_chan *chan; | ||
856 | 857 | ||
857 | sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto); | 858 | sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto); |
858 | if (!sk) | 859 | if (!sk) |
@@ -869,6 +870,14 @@ struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, g | |||
869 | sk->sk_protocol = proto; | 870 | sk->sk_protocol = proto; |
870 | sk->sk_state = BT_OPEN; | 871 | sk->sk_state = BT_OPEN; |
871 | 872 | ||
873 | chan = l2cap_chan_create(sk); | ||
874 | if (!chan) { | ||
875 | l2cap_sock_kill(sk); | ||
876 | return NULL; | ||
877 | } | ||
878 | |||
879 | l2cap_pi(sk)->chan = chan; | ||
880 | |||
872 | return sk; | 881 | return sk; |
873 | } | 882 | } |
874 | 883 | ||
@@ -876,7 +885,6 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, | |||
876 | int kern) | 885 | int kern) |
877 | { | 886 | { |
878 | struct sock *sk; | 887 | struct sock *sk; |
879 | struct l2cap_chan *chan; | ||
880 | 888 | ||
881 | BT_DBG("sock %p", sock); | 889 | BT_DBG("sock %p", sock); |
882 | 890 | ||
@@ -895,14 +903,6 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, | |||
895 | if (!sk) | 903 | if (!sk) |
896 | return -ENOMEM; | 904 | return -ENOMEM; |
897 | 905 | ||
898 | chan = l2cap_chan_create(sk); | ||
899 | if (!chan) { | ||
900 | l2cap_sock_kill(sk); | ||
901 | return -ENOMEM; | ||
902 | } | ||
903 | |||
904 | l2cap_pi(sk)->chan = chan; | ||
905 | |||
906 | l2cap_sock_init(sk, NULL); | 906 | l2cap_sock_init(sk, NULL); |
907 | return 0; | 907 | return 0; |
908 | } | 908 | } |