aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-12-09 01:45:12 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2011-12-18 14:07:56 -0500
commitd01b2ff4e6496bc48a1917b6340e13263f871a15 (patch)
treedcbaef3a745c59177c5c87671bfd7c99932bc3cd /net
parent67d0dfb5ec781e9fe030e4e61359ee6eed66ff92 (diff)
Bluetooth: convert chan_lock to mutex
spin lock doesn't fit ok anymore on the new code based on workqueues. Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/l2cap_core.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 31c94fd31611..5c5948f09a62 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -115,11 +115,11 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci
115{ 115{
116 struct l2cap_chan *c; 116 struct l2cap_chan *c;
117 117
118 read_lock(&conn->chan_lock); 118 mutex_lock(&conn->chan_lock);
119 c = __l2cap_get_chan_by_scid(conn, cid); 119 c = __l2cap_get_chan_by_scid(conn, cid);
120 if (c) 120 if (c)
121 lock_sock(c->sk); 121 lock_sock(c->sk);
122 read_unlock(&conn->chan_lock); 122 mutex_unlock(&conn->chan_lock);
123 return c; 123 return c;
124} 124}
125 125
@@ -138,11 +138,11 @@ static inline struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn
138{ 138{
139 struct l2cap_chan *c; 139 struct l2cap_chan *c;
140 140
141 read_lock(&conn->chan_lock); 141 mutex_lock(&conn->chan_lock);
142 c = __l2cap_get_chan_by_ident(conn, ident); 142 c = __l2cap_get_chan_by_ident(conn, ident);
143 if (c) 143 if (c)
144 lock_sock(c->sk); 144 lock_sock(c->sk);
145 read_unlock(&conn->chan_lock); 145 mutex_unlock(&conn->chan_lock);
146 return c; 146 return c;
147} 147}
148 148
@@ -381,9 +381,9 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
381 381
382 if (conn) { 382 if (conn) {
383 /* Delete from channel list */ 383 /* Delete from channel list */
384 write_lock_bh(&conn->chan_lock); 384 mutex_lock(&conn->chan_lock);
385 list_del(&chan->list); 385 list_del(&chan->list);
386 write_unlock_bh(&conn->chan_lock); 386 mutex_unlock(&conn->chan_lock);
387 chan_put(chan); 387 chan_put(chan);
388 388
389 chan->conn = NULL; 389 chan->conn = NULL;
@@ -754,7 +754,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
754 754
755 BT_DBG("conn %p", conn); 755 BT_DBG("conn %p", conn);
756 756
757 read_lock(&conn->chan_lock); 757 mutex_lock(&conn->chan_lock);
758 758
759 list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) { 759 list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) {
760 struct sock *sk = chan->sk; 760 struct sock *sk = chan->sk;
@@ -780,9 +780,9 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
780 &chan->conf_state)) { 780 &chan->conf_state)) {
781 /* l2cap_chan_close() calls list_del(chan) 781 /* l2cap_chan_close() calls list_del(chan)
782 * so release the lock */ 782 * so release the lock */
783 read_unlock(&conn->chan_lock); 783 mutex_unlock(&conn->chan_lock);
784 l2cap_chan_close(chan, ECONNRESET); 784 l2cap_chan_close(chan, ECONNRESET);
785 read_lock(&conn->chan_lock); 785 utex_lock(&conn->chan_lock);
786 bh_unlock_sock(sk); 786 bh_unlock_sock(sk);
787 continue; 787 continue;
788 } 788 }
@@ -838,7 +838,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
838 bh_unlock_sock(sk); 838 bh_unlock_sock(sk);
839 } 839 }
840 840
841 read_unlock(&conn->chan_lock); 841 mutex_unlock(&conn->chan_lock);
842} 842}
843 843
844/* Find socket with cid and source bdaddr. 844/* Find socket with cid and source bdaddr.
@@ -903,7 +903,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
903 903
904 sk = chan->sk; 904 sk = chan->sk;
905 905
906 write_lock_bh(&conn->chan_lock); 906 mutex_lock(&conn->chan_lock);
907 907
908 hci_conn_hold(conn->hcon); 908 hci_conn_hold(conn->hcon);
909 909
@@ -919,7 +919,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
919 l2cap_state_change(chan, BT_CONNECTED); 919 l2cap_state_change(chan, BT_CONNECTED);
920 parent->sk_data_ready(parent, 0); 920 parent->sk_data_ready(parent, 0);
921 921
922 write_unlock_bh(&conn->chan_lock); 922 mutex_unlock(&conn->chan_lock);
923 923
924clean: 924clean:
925 release_sock(parent); 925 release_sock(parent);
@@ -954,7 +954,7 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
954 if (conn->hcon->out && conn->hcon->type == LE_LINK) 954 if (conn->hcon->out && conn->hcon->type == LE_LINK)
955 smp_conn_security(conn, conn->hcon->pending_sec_level); 955 smp_conn_security(conn, conn->hcon->pending_sec_level);
956 956
957 read_lock(&conn->chan_lock); 957 mutex_lock(&conn->chan_lock);
958 958
959 list_for_each_entry(chan, &conn->chan_l, list) { 959 list_for_each_entry(chan, &conn->chan_l, list) {
960 struct sock *sk = chan->sk; 960 struct sock *sk = chan->sk;
@@ -976,7 +976,7 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
976 bh_unlock_sock(sk); 976 bh_unlock_sock(sk);
977 } 977 }
978 978
979 read_unlock(&conn->chan_lock); 979 mutex_unlock(&conn->chan_lock);
980} 980}
981 981
982/* Notify sockets that we cannot guaranty reliability anymore */ 982/* Notify sockets that we cannot guaranty reliability anymore */
@@ -986,7 +986,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err)
986 986
987 BT_DBG("conn %p", conn); 987 BT_DBG("conn %p", conn);
988 988
989 read_lock(&conn->chan_lock); 989 mutex_lock(&conn->chan_lock);
990 990
991 list_for_each_entry(chan, &conn->chan_l, list) { 991 list_for_each_entry(chan, &conn->chan_l, list) {
992 struct sock *sk = chan->sk; 992 struct sock *sk = chan->sk;
@@ -995,7 +995,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err)
995 sk->sk_err = err; 995 sk->sk_err = err;
996 } 996 }
997 997
998 read_unlock(&conn->chan_lock); 998 mutex_unlock(&conn->chan_lock);
999} 999}
1000 1000
1001static void l2cap_info_timeout(unsigned long arg) 1001static void l2cap_info_timeout(unsigned long arg)
@@ -1086,7 +1086,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status)
1086 conn->feat_mask = 0; 1086 conn->feat_mask = 0;
1087 1087
1088 spin_lock_init(&conn->lock); 1088 spin_lock_init(&conn->lock);
1089 rwlock_init(&conn->chan_lock); 1089 mutex_init(&conn->chan_lock);
1090 1090
1091 INIT_LIST_HEAD(&conn->chan_l); 1091 INIT_LIST_HEAD(&conn->chan_l);
1092 1092
@@ -1104,9 +1104,9 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status)
1104 1104
1105static inline void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) 1105static inline void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
1106{ 1106{
1107 write_lock_bh(&conn->chan_lock); 1107 mutex_lock(&conn->chan_lock);
1108 __l2cap_chan_add(conn, chan); 1108 __l2cap_chan_add(conn, chan);
1109 write_unlock_bh(&conn->chan_lock); 1109 mutex_unlock(&conn->chan_lock);
1110} 1110}
1111 1111
1112/* ---- Socket interface ---- */ 1112/* ---- Socket interface ---- */
@@ -1771,7 +1771,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
1771 1771
1772 BT_DBG("conn %p", conn); 1772 BT_DBG("conn %p", conn);
1773 1773
1774 read_lock(&conn->chan_lock); 1774 mutex_lock(&conn->chan_lock);
1775 list_for_each_entry(chan, &conn->chan_l, list) { 1775 list_for_each_entry(chan, &conn->chan_l, list) {
1776 struct sock *sk = chan->sk; 1776 struct sock *sk = chan->sk;
1777 if (chan->chan_type != L2CAP_CHAN_RAW) 1777 if (chan->chan_type != L2CAP_CHAN_RAW)
@@ -1787,7 +1787,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
1787 if (chan->ops->recv(chan->data, nskb)) 1787 if (chan->ops->recv(chan->data, nskb))
1788 kfree_skb(nskb); 1788 kfree_skb(nskb);
1789 } 1789 }
1790 read_unlock(&conn->chan_lock); 1790 mutex_unlock(&conn->chan_lock);
1791} 1791}
1792 1792
1793/* ---- L2CAP signalling commands ---- */ 1793/* ---- L2CAP signalling commands ---- */
@@ -2587,11 +2587,11 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
2587 2587
2588 sk = chan->sk; 2588 sk = chan->sk;
2589 2589
2590 write_lock_bh(&conn->chan_lock); 2590 mutex_lock(&conn->chan_lock);
2591 2591
2592 /* Check if we already have channel with that dcid */ 2592 /* Check if we already have channel with that dcid */
2593 if (__l2cap_get_chan_by_dcid(conn, scid)) { 2593 if (__l2cap_get_chan_by_dcid(conn, scid)) {
2594 write_unlock_bh(&conn->chan_lock); 2594 mutex_unlock(&conn->chan_lock);
2595 sock_set_flag(sk, SOCK_ZAPPED); 2595 sock_set_flag(sk, SOCK_ZAPPED);
2596 chan->ops->close(chan->data); 2596 chan->ops->close(chan->data);
2597 goto response; 2597 goto response;
@@ -2637,7 +2637,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
2637 status = L2CAP_CS_NO_INFO; 2637 status = L2CAP_CS_NO_INFO;
2638 } 2638 }
2639 2639
2640 write_unlock_bh(&conn->chan_lock); 2640 mutex_unlock(&conn->chan_lock);
2641 2641
2642response: 2642response:
2643 release_sock(parent); 2643 release_sock(parent);
@@ -4474,7 +4474,7 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
4474 del_timer(&conn->security_timer); 4474 del_timer(&conn->security_timer);
4475 } 4475 }
4476 4476
4477 read_lock(&conn->chan_lock); 4477 mutex_lock(&conn->chan_lock);
4478 4478
4479 list_for_each_entry(chan, &conn->chan_l, list) { 4479 list_for_each_entry(chan, &conn->chan_l, list) {
4480 struct sock *sk = chan->sk; 4480 struct sock *sk = chan->sk;
@@ -4554,7 +4554,7 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
4554 bh_unlock_sock(sk); 4554 bh_unlock_sock(sk);
4555 } 4555 }
4556 4556
4557 read_unlock(&conn->chan_lock); 4557 mutex_unlock(&conn->chan_lock);
4558 4558
4559 return 0; 4559 return 0;
4560} 4560}