aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2012-05-27 21:27:53 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2012-06-04 23:34:11 -0400
commit54a59aa2b562872781d6a8fc89f300d360941691 (patch)
treeb2414b9803565ee9e252ccfefb54c98af762ab43
parentc0df7f6e06e1aeccee39c801af7f78cadeb9f345 (diff)
Bluetooth: Add l2cap_chan->ops->ready()
This move socket specific code to l2cap_sock.c. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> 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.h1
-rw-r--r--net/bluetooth/l2cap_core.c18
-rw-r--r--net/bluetooth/l2cap_sock.c21
3 files changed, 25 insertions, 15 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 76b0e7e5dec2..c5726c24ee03 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -534,6 +534,7 @@ struct l2cap_ops {
534 void (*close) (struct l2cap_chan *chan); 534 void (*close) (struct l2cap_chan *chan);
535 void (*state_change) (struct l2cap_chan *chan, 535 void (*state_change) (struct l2cap_chan *chan,
536 int state); 536 int state);
537 void (*ready) (struct l2cap_chan *chan);
537 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, 538 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
538 unsigned long len, int nb); 539 unsigned long len, int nb);
539}; 540};
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 1f4c72074154..5947eb1c1bee 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -931,26 +931,14 @@ static void l2cap_send_conn_req(struct l2cap_chan *chan)
931 931
932static void l2cap_chan_ready(struct l2cap_chan *chan) 932static void l2cap_chan_ready(struct l2cap_chan *chan)
933{ 933{
934 struct sock *sk = chan->sk;
935 struct sock *parent;
936
937 lock_sock(sk);
938
939 parent = bt_sk(sk)->parent;
940
941 BT_DBG("sk %p, parent %p", sk, parent);
942
943 /* This clears all conf flags, including CONF_NOT_COMPLETE */ 934 /* This clears all conf flags, including CONF_NOT_COMPLETE */
944 chan->conf_state = 0; 935 chan->conf_state = 0;
945 __clear_chan_timer(chan); 936 __clear_chan_timer(chan);
946 937
947 __l2cap_state_change(chan, BT_CONNECTED); 938 chan->state = BT_CONNECTED;
948 sk->sk_state_change(sk);
949 939
950 if (parent) 940 if (chan->ops->ready)
951 parent->sk_data_ready(parent, 0); 941 chan->ops->ready(chan);
952
953 release_sock(sk);
954} 942}
955 943
956static void l2cap_do_start(struct l2cap_chan *chan) 944static void l2cap_do_start(struct l2cap_chan *chan)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 3f5946351fb9..5563023001c6 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1014,6 +1014,26 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
1014 return skb; 1014 return skb;
1015} 1015}
1016 1016
1017static void l2cap_sock_ready_cb(struct l2cap_chan *chan)
1018{
1019 struct sock *sk = chan->data;
1020 struct sock *parent;
1021
1022 lock_sock(sk);
1023
1024 parent = bt_sk(sk)->parent;
1025
1026 BT_DBG("sk %p, parent %p", sk, parent);
1027
1028 sk->sk_state = BT_CONNECTED;
1029 sk->sk_state_change(sk);
1030
1031 if (parent)
1032 parent->sk_data_ready(parent, 0);
1033
1034 release_sock(sk);
1035}
1036
1017static struct l2cap_ops l2cap_chan_ops = { 1037static struct l2cap_ops l2cap_chan_ops = {
1018 .name = "L2CAP Socket Interface", 1038 .name = "L2CAP Socket Interface",
1019 .new_connection = l2cap_sock_new_connection_cb, 1039 .new_connection = l2cap_sock_new_connection_cb,
@@ -1021,6 +1041,7 @@ static struct l2cap_ops l2cap_chan_ops = {
1021 .close = l2cap_sock_close_cb, 1041 .close = l2cap_sock_close_cb,
1022 .teardown = l2cap_sock_teardown_cb, 1042 .teardown = l2cap_sock_teardown_cb,
1023 .state_change = l2cap_sock_state_change_cb, 1043 .state_change = l2cap_sock_state_change_cb,
1044 .ready = l2cap_sock_ready_cb,
1024 .alloc_skb = l2cap_sock_alloc_skb_cb, 1045 .alloc_skb = l2cap_sock_alloc_skb_cb,
1025}; 1046};
1026 1047