diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-02-23 12:42:23 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-02-23 15:24:26 -0500 |
commit | 8f2a0601a5d68d0dbd2221613dda7fb6fee32a6b (patch) | |
tree | 13d963eed1cd1450471c9828f0432b07d4e26563 | |
parent | 85030be4c5ce39e709b2cb5d4f8ee8779af8e50b (diff) |
Bluetooth: Use hci_update_random_address() for enabling advertising
When we enable advertising we need to update the local random address if
necessary. This patch takes advantage of the hci_update_random_address()
function to set the own_address_type variable and to update the local
random address if necessary.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | net/bluetooth/mgmt.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4522da18d8e5..8df287ba9ba3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -839,13 +839,17 @@ static void enable_advertising(struct hci_request *req) | |||
839 | { | 839 | { |
840 | struct hci_dev *hdev = req->hdev; | 840 | struct hci_dev *hdev = req->hdev; |
841 | struct hci_cp_le_set_adv_param cp; | 841 | struct hci_cp_le_set_adv_param cp; |
842 | u8 enable = 0x01; | 842 | u8 own_addr_type, enable = 0x01; |
843 | 843 | ||
844 | memset(&cp, 0, sizeof(cp)); | 844 | memset(&cp, 0, sizeof(cp)); |
845 | |||
846 | if (hci_update_random_address(req, &own_addr_type) < 0) | ||
847 | return; | ||
848 | |||
845 | cp.min_interval = __constant_cpu_to_le16(0x0800); | 849 | cp.min_interval = __constant_cpu_to_le16(0x0800); |
846 | cp.max_interval = __constant_cpu_to_le16(0x0800); | 850 | cp.max_interval = __constant_cpu_to_le16(0x0800); |
847 | cp.type = get_adv_type(hdev); | 851 | cp.type = get_adv_type(hdev); |
848 | cp.own_address_type = hdev->own_addr_type; | 852 | cp.own_address_type = own_addr_type; |
849 | cp.channel_map = hdev->le_adv_channel_map; | 853 | cp.channel_map = hdev->le_adv_channel_map; |
850 | 854 | ||
851 | hci_req_add(req, HCI_OP_LE_SET_ADV_PARAM, sizeof(cp), &cp); | 855 | hci_req_add(req, HCI_OP_LE_SET_ADV_PARAM, sizeof(cp), &cp); |