]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
Bluetooth: AMP: Use set_bit / test_bit for amp_mgr state
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Fri, 7 Dec 2012 12:59:08 +0000 (14:59 +0200)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>
Wed, 9 Jan 2013 19:05:05 +0000 (17:05 -0200)
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>
include/net/bluetooth/a2mp.h
net/bluetooth/a2mp.c
net/bluetooth/amp.c

index 8b39327a5200b72473628fa4c7996f181c46e4ac..487b54c1308fdec26ddc48e46b4973200b45022a 100644 (file)
@@ -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;
index a200edf63117842ca6b35f279d45a5335541f106..eb0f4b16ff099611fb6ea0aa43add29bd1c1173f 100644 (file)
@@ -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;
index 6b829b28eb809b05c23d5fe4c7279e320839c234..d459ed43c779d776e453634db290d08f48d5a7c7 100644 (file)
@@ -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);