diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2015-11-30 04:21:45 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-12-09 18:51:50 -0500 |
commit | cab054ab47fa3fdf1c597a9874363680bfdab33e (patch) | |
tree | 66de00bdcdbf62da735338ae63cd340d60035cc1 /net/bluetooth/mgmt.c | |
parent | d6b7e2cddb72a87c2597af43ba9f5f2b03a2208b (diff) |
Bluetooth: Clean up current advertising instance tracking
We can simplify a lot of code by making sure hdev->cur_adv_instance is
always up-to-date. This allows e.g. the removal of the
get_current_adv_instance() helper function and the special
HCI_ADV_CURRENT value. This patch also makes selecting instance 0x00
explicit in the various calls where advertising instances aren't
enabled, e.g. when HCI_ADVERTISING is set or we've just finished
enabling LE.
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 | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 03a65e89a7d7..621f6fdd0dd1 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1626,8 +1626,8 @@ static void le_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode) | |||
1626 | struct hci_request req; | 1626 | struct hci_request req; |
1627 | 1627 | ||
1628 | hci_req_init(&req, hdev); | 1628 | hci_req_init(&req, hdev); |
1629 | __hci_req_update_adv_data(&req, HCI_ADV_CURRENT); | 1629 | __hci_req_update_adv_data(&req, 0x00); |
1630 | __hci_req_update_scan_rsp_data(&req, HCI_ADV_CURRENT); | 1630 | __hci_req_update_scan_rsp_data(&req, 0x00); |
1631 | hci_req_run(&req, NULL); | 1631 | hci_req_run(&req, NULL); |
1632 | hci_update_background_scan(hdev); | 1632 | hci_update_background_scan(hdev); |
1633 | } | 1633 | } |
@@ -3006,7 +3006,7 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3006 | * no need to udpate the advertising data here. | 3006 | * no need to udpate the advertising data here. |
3007 | */ | 3007 | */ |
3008 | if (lmp_le_capable(hdev)) | 3008 | if (lmp_le_capable(hdev)) |
3009 | __hci_req_update_scan_rsp_data(&req, HCI_ADV_CURRENT); | 3009 | __hci_req_update_scan_rsp_data(&req, hdev->cur_adv_instance); |
3010 | 3010 | ||
3011 | err = hci_req_run(&req, set_name_complete); | 3011 | err = hci_req_run(&req, set_name_complete); |
3012 | if (err < 0) | 3012 | if (err < 0) |
@@ -3799,6 +3799,7 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3799 | bool changed; | 3799 | bool changed; |
3800 | 3800 | ||
3801 | if (cp->val) { | 3801 | if (cp->val) { |
3802 | hdev->cur_adv_instance = 0x00; | ||
3802 | changed = !hci_dev_test_and_set_flag(hdev, HCI_ADVERTISING); | 3803 | changed = !hci_dev_test_and_set_flag(hdev, HCI_ADVERTISING); |
3803 | if (cp->val == 0x02) | 3804 | if (cp->val == 0x02) |
3804 | hci_dev_set_flag(hdev, HCI_ADVERTISING_CONNECTABLE); | 3805 | hci_dev_set_flag(hdev, HCI_ADVERTISING_CONNECTABLE); |
@@ -3846,6 +3847,7 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3846 | * We cannot use update_[adv|scan_rsp]_data() here as the | 3847 | * We cannot use update_[adv|scan_rsp]_data() here as the |
3847 | * HCI_ADVERTISING flag is not yet set. | 3848 | * HCI_ADVERTISING flag is not yet set. |
3848 | */ | 3849 | */ |
3850 | hdev->cur_adv_instance = 0x00; | ||
3849 | __hci_req_update_adv_data(&req, 0x00); | 3851 | __hci_req_update_adv_data(&req, 0x00); |
3850 | __hci_req_update_scan_rsp_data(&req, 0x00); | 3852 | __hci_req_update_scan_rsp_data(&req, 0x00); |
3851 | __hci_req_enable_advertising(&req); | 3853 | __hci_req_enable_advertising(&req); |
@@ -4195,7 +4197,7 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
4195 | /* Since only the advertising data flags will change, there | 4197 | /* Since only the advertising data flags will change, there |
4196 | * is no need to update the scan response data. | 4198 | * is no need to update the scan response data. |
4197 | */ | 4199 | */ |
4198 | __hci_req_update_adv_data(&req, HCI_ADV_CURRENT); | 4200 | __hci_req_update_adv_data(&req, hdev->cur_adv_instance); |
4199 | 4201 | ||
4200 | err = hci_req_run(&req, set_bredr_complete); | 4202 | err = hci_req_run(&req, set_bredr_complete); |
4201 | if (err < 0) | 4203 | if (err < 0) |