diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2015-02-18 07:53:55 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-02-19 02:44:28 -0500 |
commit | fba7ecf09bc458b15f9d578e4213c8c349f9592d (patch) | |
tree | b479fe60d7d4d2853cf3c9cd740414c9125f8364 /include/net | |
parent | 00629e0fd56d528f0da4d9606726a4e22e576ace (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.h | 18 |
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 { | |||
499 | extern struct list_head hci_dev_list; | 499 | extern struct list_head hci_dev_list; |
500 | extern struct list_head hci_cb_list; | 500 | extern struct list_head hci_cb_list; |
501 | extern rwlock_t hci_dev_list_lock; | 501 | extern rwlock_t hci_dev_list_lock; |
502 | extern rwlock_t hci_cb_list_lock; | 502 | extern struct mutex hci_cb_list_lock; |
503 | 503 | ||
504 | /* ----- HCI interface to upper protocols ----- */ | 504 | /* ----- HCI interface to upper protocols ----- */ |
505 | int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); | 505 | int 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 | ||
1171 | static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, | 1171 | static 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 | ||
1192 | static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) | 1192 | static 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 | ||
1204 | static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, | 1204 | static 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 | ||
1217 | static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) | 1217 | static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) |