diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-02-23 12:42:24 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-02-23 15:24:26 -0500 |
commit | d9483943601ba7095af42a159faacf7746a74bc9 (patch) | |
tree | a42c4f5089071019bf70a63da028f763b965ffc4 /net/bluetooth/mgmt.c | |
parent | 8f2a0601a5d68d0dbd2221613dda7fb6fee32a6b (diff) |
Bluetooth: Use hci_update_random_address() for initiating LE scan
When we start LE scanning we need to update the local random address if
necessary. This patch updates the code to use hci_update_random_address()
for setting the own_address_type scan parameter and updating the local
random address if necessary.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 8df287ba9ba3..e369c871c702 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -3294,7 +3294,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev, | |||
3294 | struct hci_request req; | 3294 | struct hci_request req; |
3295 | /* General inquiry access code (GIAC) */ | 3295 | /* General inquiry access code (GIAC) */ |
3296 | u8 lap[3] = { 0x33, 0x8b, 0x9e }; | 3296 | u8 lap[3] = { 0x33, 0x8b, 0x9e }; |
3297 | u8 status; | 3297 | u8 status, own_addr_type; |
3298 | int err; | 3298 | int err; |
3299 | 3299 | ||
3300 | BT_DBG("%s", hdev->name); | 3300 | BT_DBG("%s", hdev->name); |
@@ -3387,10 +3387,19 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev, | |||
3387 | } | 3387 | } |
3388 | 3388 | ||
3389 | memset(¶m_cp, 0, sizeof(param_cp)); | 3389 | memset(¶m_cp, 0, sizeof(param_cp)); |
3390 | |||
3391 | err = hci_update_random_address(&req, &own_addr_type); | ||
3392 | if (err < 0) { | ||
3393 | err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, | ||
3394 | MGMT_STATUS_FAILED); | ||
3395 | mgmt_pending_remove(cmd); | ||
3396 | goto failed; | ||
3397 | } | ||
3398 | |||
3390 | param_cp.type = LE_SCAN_ACTIVE; | 3399 | param_cp.type = LE_SCAN_ACTIVE; |
3391 | param_cp.interval = cpu_to_le16(DISCOV_LE_SCAN_INT); | 3400 | param_cp.interval = cpu_to_le16(DISCOV_LE_SCAN_INT); |
3392 | param_cp.window = cpu_to_le16(DISCOV_LE_SCAN_WIN); | 3401 | param_cp.window = cpu_to_le16(DISCOV_LE_SCAN_WIN); |
3393 | param_cp.own_address_type = hdev->own_addr_type; | 3402 | param_cp.own_address_type = own_addr_type; |
3394 | hci_req_add(&req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp), | 3403 | hci_req_add(&req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp), |
3395 | ¶m_cp); | 3404 | ¶m_cp); |
3396 | 3405 | ||