summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2012-12-07 12:59:08 (GMT)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-01-09 19:05:05 (GMT)
commitcb6801c640c759fe02c812728c2661bd8ba5a302 (patch)
tree41a0c3980eb805049de1cbc654a90284131a1b98
parentcbf54ad104cb2ec6f5734d95be1dc783bea0343b (diff)
downloadlinux-cb6801c640c759fe02c812728c2661bd8ba5a302.tar.xz
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: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
-rw-r--r--include/net/bluetooth/a2mp.h2
-rw-r--r--net/bluetooth/a2mp.c6
-rw-r--r--net/bluetooth/amp.c4
3 files changed, 6 insertions, 6 deletions
diff --git a/include/net/bluetooth/a2mp.h b/include/net/bluetooth/a2mp.h
index 8b39327..487b54c 100644
--- a/include/net/bluetooth/a2mp.h
+++ b/include/net/bluetooth/a2mp.h
@@ -34,7 +34,7 @@ struct amp_mgr {
struct kref kref;
__u8 ident;
__u8 handle;
- enum amp_mgr_state state;
+ unsigned long state;
unsigned long flags;
struct list_head amp_ctrls;
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index a200edf..eb0f4b1 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -290,7 +290,7 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
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);
done:
@@ -506,7 +506,7 @@ send_rsp:
a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, hdr->ident,
sizeof(rsp), &rsp);
} else {
- mgr->state = WRITE_REMOTE_AMP_ASSOC;
+ set_bit(WRITE_REMOTE_AMP_ASSOC, &mgr->state);
mgr->ident = hdr->ident;
}
@@ -848,7 +848,7 @@ struct amp_mgr *amp_mgr_lookup_by_state(u8 state)
mutex_lock(&amp_mgr_list_lock);
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);
mutex_unlock(&amp_mgr_list_lock);
return mgr;
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index 6b829b2..d459ed4 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -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);
- 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);
}
@@ -250,7 +250,7 @@ void amp_read_loc_assoc_final_data(struct hci_dev *hdev,
cp.len_so_far = cpu_to_le16(0);
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 */
hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, sizeof(cp), &cp);