Bluetooth: Store Bluetooth address from controller setup
authorMarcel Holtmann <marcel@holtmann.org>
Sat, 5 Jul 2014 08:48:03 +0000 (10:48 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Sat, 5 Jul 2014 12:48:28 +0000 (15:48 +0300)
During the setup phase of a controller, the Bluetooth address will be
read and to have that original address available for later use, store
it as setup address.

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

index 1cae4d3a629deeb4414cf7dfc3fbd05276992913..aff285698c8511deae1465c041c2fa23778a0b31 100644 (file)
@@ -171,6 +171,7 @@ struct hci_dev {
        __u8            bus;
        __u8            dev_type;
        bdaddr_t        bdaddr;
+       bdaddr_t        setup_addr;
        bdaddr_t        public_addr;
        bdaddr_t        random_addr;
        bdaddr_t        static_addr;
index 013c371d3c87d7b28e171bcbef8407ce9a30e904..c2ba79c8fe51c6be49a0202b0f6c3594b879e332 100644 (file)
@@ -645,8 +645,14 @@ static void hci_cc_read_bd_addr(struct hci_dev *hdev, struct sk_buff *skb)
 
        BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
 
-       if (!rp->status)
+       if (rp->status)
+               return;
+
+       if (test_bit(HCI_INIT, &hdev->flags))
                bacpy(&hdev->bdaddr, &rp->bdaddr);
+
+       if (test_bit(HCI_SETUP, &hdev->dev_flags))
+               bacpy(&hdev->setup_addr, &rp->bdaddr);
 }
 
 static void hci_cc_read_page_scan_activity(struct hci_dev *hdev,