aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-02-18 07:53:55 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-02-19 02:44:28 -0500
commitfba7ecf09bc458b15f9d578e4213c8c349f9592d (patch)
treeb479fe60d7d4d2853cf3c9cd740414c9125f8364 /include/net
parent00629e0fd56d528f0da4d9606726a4e22e576ace (diff)
Bluetooth: Convert hci_cb_list_lock to a mutex
We'll soon need to be able to sleep inside the loops that iterate the hci_cb list, so neither a spinlock, rwlock or rcu are usable. This patch changes the lock to a mutex which permits sleeping while holding the lock. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/bluetooth/hci_core.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 5f1ca3359c1a..137a18226975 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -499,7 +499,7 @@ struct hci_conn_params {
499extern struct list_head hci_dev_list; 499extern struct list_head hci_dev_list;
500extern struct list_head hci_cb_list; 500extern struct list_head hci_cb_list;
501extern rwlock_t hci_dev_list_lock; 501extern rwlock_t hci_dev_list_lock;
502extern rwlock_t hci_cb_list_lock; 502extern struct mutex hci_cb_list_lock;
503 503
504/* ----- HCI interface to upper protocols ----- */ 504/* ----- HCI interface to upper protocols ----- */
505int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); 505int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr);
@@ -1160,12 +1160,12 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
1160 1160
1161 encrypt = test_bit(HCI_CONN_ENCRYPT, &conn->flags) ? 0x01 : 0x00; 1161 encrypt = test_bit(HCI_CONN_ENCRYPT, &conn->flags) ? 0x01 : 0x00;
1162 1162
1163 read_lock(&hci_cb_list_lock); 1163 mutex_lock(&hci_cb_list_lock);
1164 list_for_each_entry(cb, &hci_cb_list, list) { 1164 list_for_each_entry(cb, &hci_cb_list, list) {
1165 if (cb->security_cfm) 1165 if (cb->security_cfm)
1166 cb->security_cfm(conn, status, encrypt); 1166 cb->security_cfm(conn, status, encrypt);
1167 } 1167 }
1168 read_unlock(&hci_cb_list_lock); 1168 mutex_unlock(&hci_cb_list_lock);
1169} 1169}
1170 1170
1171static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, 1171static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
@@ -1181,24 +1181,24 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
1181 1181
1182 hci_proto_encrypt_cfm(conn, status, encrypt); 1182 hci_proto_encrypt_cfm(conn, status, encrypt);
1183 1183
1184 read_lock(&hci_cb_list_lock); 1184 mutex_lock(&hci_cb_list_lock);
1185 list_for_each_entry(cb, &hci_cb_list, list) { 1185 list_for_each_entry(cb, &hci_cb_list, list) {
1186 if (cb->security_cfm) 1186 if (cb->security_cfm)
1187 cb->security_cfm(conn, status, encrypt); 1187 cb->security_cfm(conn, status, encrypt);
1188 } 1188 }
1189 read_unlock(&hci_cb_list_lock); 1189 mutex_unlock(&hci_cb_list_lock);
1190} 1190}
1191 1191
1192static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) 1192static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status)
1193{ 1193{
1194 struct hci_cb *cb; 1194 struct hci_cb *cb;
1195 1195
1196 read_lock(&hci_cb_list_lock); 1196 mutex_lock(&hci_cb_list_lock);
1197 list_for_each_entry(cb, &hci_cb_list, list) { 1197 list_for_each_entry(cb, &hci_cb_list, list) {
1198 if (cb->key_change_cfm) 1198 if (cb->key_change_cfm)
1199 cb->key_change_cfm(conn, status); 1199 cb->key_change_cfm(conn, status);
1200 } 1200 }
1201 read_unlock(&hci_cb_list_lock); 1201 mutex_unlock(&hci_cb_list_lock);
1202} 1202}
1203 1203
1204static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, 1204static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status,
@@ -1206,12 +1206,12 @@ static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status,
1206{ 1206{
1207 struct hci_cb *cb; 1207 struct hci_cb *cb;
1208 1208
1209 read_lock(&hci_cb_list_lock); 1209 mutex_lock(&hci_cb_list_lock);
1210 list_for_each_entry(cb, &hci_cb_list, list) { 1210 list_for_each_entry(cb, &hci_cb_list, list) {
1211 if (cb->role_switch_cfm) 1211 if (cb->role_switch_cfm)
1212 cb->role_switch_cfm(conn, status, role); 1212 cb->role_switch_cfm(conn, status, role);
1213 } 1213 }
1214 read_unlock(&hci_cb_list_lock); 1214 mutex_unlock(&hci_cb_list_lock);
1215} 1215}
1216 1216
1217static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) 1217static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type)