提交 cb6801c6 编写于 作者: A Andrei Emeltchenko 提交者: Gustavo Padovan

Bluetooth: AMP: Use set_bit / test_bit for amp_mgr state

Using bit operations solves problems with multiple requests
and clearing state.
Signed-off-by: NAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: NGustavo Padovan <gustavo.padovan@collabora.co.uk>
上级 cbf54ad1
...@@ -34,7 +34,7 @@ struct amp_mgr { ...@@ -34,7 +34,7 @@ struct amp_mgr {
struct kref kref; struct kref kref;
__u8 ident; __u8 ident;
__u8 handle; __u8 handle;
enum amp_mgr_state state; unsigned long state;
unsigned long flags; unsigned long flags;
struct list_head amp_ctrls; struct list_head amp_ctrls;
......
...@@ -290,7 +290,7 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, ...@@ -290,7 +290,7 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
goto done; goto done;
} }
mgr->state = READ_LOC_AMP_INFO; set_bit(READ_LOC_AMP_INFO, &mgr->state);
hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL); hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL);
done: done:
...@@ -506,7 +506,7 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, ...@@ -506,7 +506,7 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, hdr->ident, a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, hdr->ident,
sizeof(rsp), &rsp); sizeof(rsp), &rsp);
} else { } else {
mgr->state = WRITE_REMOTE_AMP_ASSOC; set_bit(WRITE_REMOTE_AMP_ASSOC, &mgr->state);
mgr->ident = hdr->ident; mgr->ident = hdr->ident;
} }
...@@ -848,7 +848,7 @@ struct amp_mgr *amp_mgr_lookup_by_state(u8 state) ...@@ -848,7 +848,7 @@ struct amp_mgr *amp_mgr_lookup_by_state(u8 state)
mutex_lock(&amp_mgr_list_lock); mutex_lock(&amp_mgr_list_lock);
list_for_each_entry(mgr, &amp_mgr_list, list) { list_for_each_entry(mgr, &amp_mgr_list, list) {
if (mgr->state == state) { if (test_and_clear_bit(state, &mgr->state)) {
amp_mgr_get(mgr); amp_mgr_get(mgr);
mutex_unlock(&amp_mgr_list_lock); mutex_unlock(&amp_mgr_list_lock);
return mgr; return mgr;
......
...@@ -236,7 +236,7 @@ void amp_read_loc_assoc(struct hci_dev *hdev, struct amp_mgr *mgr) ...@@ -236,7 +236,7 @@ void amp_read_loc_assoc(struct hci_dev *hdev, struct amp_mgr *mgr)
cp.max_len = cpu_to_le16(hdev->amp_assoc_size); cp.max_len = cpu_to_le16(hdev->amp_assoc_size);
mgr->state = READ_LOC_AMP_ASSOC; set_bit(READ_LOC_AMP_ASSOC, &mgr->state);
hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, sizeof(cp), &cp); hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, sizeof(cp), &cp);
} }
...@@ -250,7 +250,7 @@ void amp_read_loc_assoc_final_data(struct hci_dev *hdev, ...@@ -250,7 +250,7 @@ void amp_read_loc_assoc_final_data(struct hci_dev *hdev,
cp.len_so_far = cpu_to_le16(0); cp.len_so_far = cpu_to_le16(0);
cp.max_len = cpu_to_le16(hdev->amp_assoc_size); cp.max_len = cpu_to_le16(hdev->amp_assoc_size);
mgr->state = READ_LOC_AMP_ASSOC_FINAL; set_bit(READ_LOC_AMP_ASSOC_FINAL, &mgr->state);
/* Read Local AMP Assoc final link information data */ /* Read Local AMP Assoc final link information data */
hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, sizeof(cp), &cp); hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, sizeof(cp), &cp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册