diff options
author | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2013-10-15 18:24:47 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2013-10-15 19:42:44 -0400 |
commit | 8d836d71e2223b8961b21112bb4ce89ef8231682 (patch) | |
tree | b7f6c82cf7a2b1fabbda72e1af060b3a06d71cb7 /net | |
parent | f8e73017c15b007bd519d0049305bb377e8cc1f5 (diff) |
Bluetooth: Access sk_sndtimeo indirectly in l2cap_core.c
As part of the work to remove struct sock from l2cap_core.c and make it
more generic we remove in this commit the direct access to sk->sk_sndtimeo
member. This objective of this change is purely remove sk usage from
l2cap_core.c
Now we have a new l2cap ops to get the current value of sk->sndtimeo. A
l2cap_chan_no_get_sndtimeo was added for users of L2CAP that doesn't need
to set a timeout.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/a2mp.c | 1 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 8 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 8 |
3 files changed, 12 insertions, 5 deletions
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c index 6b8cc23787e2..1e9921024a1d 100644 --- a/net/bluetooth/a2mp.c +++ b/net/bluetooth/a2mp.c | |||
@@ -710,6 +710,7 @@ static struct l2cap_ops a2mp_chan_ops = { | |||
710 | .teardown = l2cap_chan_no_teardown, | 710 | .teardown = l2cap_chan_no_teardown, |
711 | .ready = l2cap_chan_no_ready, | 711 | .ready = l2cap_chan_no_ready, |
712 | .defer = l2cap_chan_no_defer, | 712 | .defer = l2cap_chan_no_defer, |
713 | .get_sndtimeo = l2cap_chan_no_get_sndtimeo, | ||
713 | }; | 714 | }; |
714 | 715 | ||
715 | static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked) | 716 | static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked) |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index f4e02b453984..c6334fc86d1d 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -649,8 +649,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) | |||
649 | case BT_CONFIG: | 649 | case BT_CONFIG: |
650 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && | 650 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && |
651 | conn->hcon->type == ACL_LINK) { | 651 | conn->hcon->type == ACL_LINK) { |
652 | struct sock *sk = chan->sk; | 652 | __set_chan_timer(chan, chan->ops->get_sndtimeo(chan)); |
653 | __set_chan_timer(chan, sk->sk_sndtimeo); | ||
654 | l2cap_send_disconn_req(chan, reason); | 653 | l2cap_send_disconn_req(chan, reason); |
655 | } else | 654 | } else |
656 | l2cap_chan_del(chan, reason); | 655 | l2cap_chan_del(chan, reason); |
@@ -1764,7 +1763,6 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, | |||
1764 | int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | 1763 | int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, |
1765 | bdaddr_t *dst, u8 dst_type) | 1764 | bdaddr_t *dst, u8 dst_type) |
1766 | { | 1765 | { |
1767 | struct sock *sk = chan->sk; | ||
1768 | struct l2cap_conn *conn; | 1766 | struct l2cap_conn *conn; |
1769 | struct hci_conn *hcon; | 1767 | struct hci_conn *hcon; |
1770 | struct hci_dev *hdev; | 1768 | struct hci_dev *hdev; |
@@ -1876,7 +1874,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
1876 | hci_conn_drop(hcon); | 1874 | hci_conn_drop(hcon); |
1877 | 1875 | ||
1878 | l2cap_state_change(chan, BT_CONNECT); | 1876 | l2cap_state_change(chan, BT_CONNECT); |
1879 | __set_chan_timer(chan, sk->sk_sndtimeo); | 1877 | __set_chan_timer(chan, chan->ops->get_sndtimeo(chan)); |
1880 | 1878 | ||
1881 | if (hcon->state == BT_CONNECTED) { | 1879 | if (hcon->state == BT_CONNECTED) { |
1882 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { | 1880 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { |
@@ -3817,7 +3815,7 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn, | |||
3817 | 3815 | ||
3818 | dcid = chan->scid; | 3816 | dcid = chan->scid; |
3819 | 3817 | ||
3820 | __set_chan_timer(chan, sk->sk_sndtimeo); | 3818 | __set_chan_timer(chan, chan->ops->get_sndtimeo(chan)); |
3821 | 3819 | ||
3822 | chan->ident = cmd->ident; | 3820 | chan->ident = cmd->ident; |
3823 | 3821 | ||
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 0de8a30c06a1..ffa78d3cd8ac 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -1136,6 +1136,13 @@ static void l2cap_sock_resume_cb(struct l2cap_chan *chan) | |||
1136 | sk->sk_state_change(sk); | 1136 | sk->sk_state_change(sk); |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | static long l2cap_sock_get_sndtimeo_cb(struct l2cap_chan *chan) | ||
1140 | { | ||
1141 | struct sock *sk = chan->data; | ||
1142 | |||
1143 | return sk->sk_sndtimeo; | ||
1144 | } | ||
1145 | |||
1139 | static struct l2cap_ops l2cap_chan_ops = { | 1146 | static struct l2cap_ops l2cap_chan_ops = { |
1140 | .name = "L2CAP Socket Interface", | 1147 | .name = "L2CAP Socket Interface", |
1141 | .new_connection = l2cap_sock_new_connection_cb, | 1148 | .new_connection = l2cap_sock_new_connection_cb, |
@@ -1146,6 +1153,7 @@ static struct l2cap_ops l2cap_chan_ops = { | |||
1146 | .ready = l2cap_sock_ready_cb, | 1153 | .ready = l2cap_sock_ready_cb, |
1147 | .defer = l2cap_sock_defer_cb, | 1154 | .defer = l2cap_sock_defer_cb, |
1148 | .resume = l2cap_sock_resume_cb, | 1155 | .resume = l2cap_sock_resume_cb, |
1156 | .get_sndtimeo = l2cap_sock_get_sndtimeo_cb, | ||
1149 | .alloc_skb = l2cap_sock_alloc_skb_cb, | 1157 | .alloc_skb = l2cap_sock_alloc_skb_cb, |
1150 | }; | 1158 | }; |
1151 | 1159 | ||