Bluetooth: Use real advertising state to random address update decision
authorJohan Hedberg <johan.hedberg@intel.com>
Tue, 8 Jul 2014 12:07:49 +0000 (15:07 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 8 Jul 2014 12:22:06 +0000 (14:22 +0200)
Now that we have a flag for tracking the real advertising state we
should use that to determine whether it's safe to update the random
address or not. The couple of places that were clearing the flag due to
a pending request need to be updated too.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_conn.c
net/bluetooth/hci_core.c
net/bluetooth/mgmt.c

index 16fd55da9c1df5d1a1eced21d95e88bc4b6e2960..0db2579ea6c61c5bd49a09dbfa24f2f3c167a6ea 100644 (file)
@@ -671,12 +671,12 @@ static void hci_req_directed_advertising(struct hci_request *req,
        enable = 0x00;
        hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable);
 
-       /* Clear the HCI_ADVERTISING bit temporarily so that the
+       /* Clear the HCI_LE_ADV bit temporarily so that the
         * hci_update_random_address knows that it's safe to go ahead
         * and write a new random address. The flag will be set back on
         * as soon as the SET_ADV_ENABLE HCI command completes.
         */
-       clear_bit(HCI_ADVERTISING, &hdev->dev_flags);
+       clear_bit(HCI_LE_ADV, &hdev->dev_flags);
 
        /* Set require_privacy to false so that the remote device has a
         * chance of identifying us.
index f1c5a077e5584e7fbcb8bfcd68a550bfb5664671..8ffaca0290f891806d00a294ab884a53a05003ed 100644 (file)
@@ -3746,7 +3746,7 @@ static void set_random_addr(struct hci_request *req, bdaddr_t *rpa)
         * In this kind of scenario skip the update and let the random
         * address be updated at the next cycle.
         */
-       if (test_bit(HCI_ADVERTISING, &hdev->dev_flags) ||
+       if (test_bit(HCI_LE_ADV, &hdev->dev_flags) ||
            hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT)) {
                BT_DBG("Deferring random address update");
                return;
index dda1eb124208a29baf30e3080b686194bab694b4..be589d8d437fdcc1f94001d9e5627fb31a4dbf74 100644 (file)
@@ -1046,12 +1046,12 @@ static void enable_advertising(struct hci_request *req)
        u8 own_addr_type, enable = 0x01;
        bool connectable;
 
-       /* Clear the HCI_ADVERTISING bit temporarily so that the
+       /* Clear the HCI_LE_ADV bit temporarily so that the
         * hci_update_random_address knows that it's safe to go ahead
         * and write a new random address. The flag will be set back on
         * as soon as the SET_ADV_ENABLE HCI command completes.
         */
-       clear_bit(HCI_ADVERTISING, &hdev->dev_flags);
+       clear_bit(HCI_LE_ADV, &hdev->dev_flags);
 
        connectable = get_connectable(hdev);