aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-10-15 18:24:45 -0400
committerMarcel Holtmann <marcel@holtmann.org>2013-10-15 19:42:44 -0400
commit53f5212121fc3bcd0bccb8841c01e08ca942f333 (patch)
tree3beab58217470ea83433cf8ba14c7e4a91d3a80c /net
parentd1967ff88b3854d1bb002cccd15d28ad0d9223a9 (diff)
Bluetooth: Extend state_change() call to report errors too
Instead of creating an new function pointer to report errors we are just reusing state_change for that and there is a simple reason for this, one place in the l2cap_core.c code needs, in a locked sk, set both the sk_state and sk_err. If we create two different functions for this we would need to release the lock between the two operation putting the socket in non desired state. The change is transparent to the l2cap_core.c code, user that only needs to set the state won't need any modification. This is another step of an ongoing work to make l2cap_core.c totally independent from l2cap's struct sock. 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.c3
-rw-r--r--net/bluetooth/l2cap_core.c6
-rw-r--r--net/bluetooth/l2cap_sock.c6
3 files changed, 9 insertions, 6 deletions
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index 60ca52819247..6b8cc23787e2 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -672,7 +672,8 @@ static void a2mp_chan_close_cb(struct l2cap_chan *chan)
672 l2cap_chan_put(chan); 672 l2cap_chan_put(chan);
673} 673}
674 674
675static void a2mp_chan_state_change_cb(struct l2cap_chan *chan, int state) 675static void a2mp_chan_state_change_cb(struct l2cap_chan *chan, int state,
676 int err)
676{ 677{
677 struct amp_mgr *mgr = chan->data; 678 struct amp_mgr *mgr = chan->data;
678 679
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 0c3446da1ec9..df5670d8e11d 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -229,7 +229,7 @@ static void __l2cap_state_change(struct l2cap_chan *chan, int state)
229 state_to_string(state)); 229 state_to_string(state));
230 230
231 chan->state = state; 231 chan->state = state;
232 chan->ops->state_change(chan, state); 232 chan->ops->state_change(chan, state, 0);
233} 233}
234 234
235static void l2cap_state_change(struct l2cap_chan *chan, int state) 235static void l2cap_state_change(struct l2cap_chan *chan, int state)
@@ -243,9 +243,7 @@ static void l2cap_state_change(struct l2cap_chan *chan, int state)
243 243
244static inline void __l2cap_chan_set_err(struct l2cap_chan *chan, int err) 244static inline void __l2cap_chan_set_err(struct l2cap_chan *chan, int err)
245{ 245{
246 struct sock *sk = chan->sk; 246 chan->ops->state_change(chan, chan->state, err);
247
248 sk->sk_err = err;
249} 247}
250 248
251static inline void l2cap_chan_set_err(struct l2cap_chan *chan, int err) 249static inline void l2cap_chan_set_err(struct l2cap_chan *chan, int err)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 5ffd75e20bde..0de8a30c06a1 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1072,11 +1072,15 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err)
1072 release_sock(sk); 1072 release_sock(sk);
1073} 1073}
1074 1074
1075static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state) 1075static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state,
1076 int err)
1076{ 1077{
1077 struct sock *sk = chan->data; 1078 struct sock *sk = chan->data;
1078 1079
1079 sk->sk_state = state; 1080 sk->sk_state = state;
1081
1082 if (err)
1083 sk->sk_err = err;
1080} 1084}
1081 1085
1082static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan, 1086static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,