summaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-11-30 04:21:44 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-12-09 18:51:50 -0500
commitd6b7e2cddb72a87c2597af43ba9f5f2b03a2208b (patch)
tree32254aefb08fc902d8bf24da0d2876758975c73c /net/bluetooth
parent550a8ca765a154ca38dcd888b4f12a173e761bdc (diff)
Bluetooth: Clean up advertising initialization in powered_update_hci()
The logic in powered_update_hci() to initialize the advertising data & state is a bit more complicated than it needs to be. It was previously not doing anything if HCI_LE_ENABLED wasn't set, but this was not obvious by quickly looking at the code. Now the conditions for the various actions are more explicit. Another simplification is due to the fact that __hci_req_schedule_adv_instance() takes care of setting hdev->cur_adv_instance so there's no need to set it before calling the function. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_request.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index f1529d7740f6..14db777a6bb1 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -2181,7 +2181,6 @@ static void discov_off(struct work_struct *work)
2181static int powered_update_hci(struct hci_request *req, unsigned long opt) 2181static int powered_update_hci(struct hci_request *req, unsigned long opt)
2182{ 2182{
2183 struct hci_dev *hdev = req->hdev; 2183 struct hci_dev *hdev = req->hdev;
2184 struct adv_info *adv_instance;
2185 u8 link_sec; 2184 u8 link_sec;
2186 2185
2187 hci_dev_lock(hdev); 2186 hci_dev_lock(hdev);
@@ -2216,32 +2215,27 @@ static int powered_update_hci(struct hci_request *req, unsigned long opt)
2216 sizeof(cp), &cp); 2215 sizeof(cp), &cp);
2217 } 2216 }
2218 2217
2219 if (lmp_le_capable(hdev)) { 2218 if (hci_dev_test_flag(hdev, HCI_LE_ENABLED)) {
2220 /* Make sure the controller has a good default for 2219 /* Make sure the controller has a good default for
2221 * advertising data. This also applies to the case 2220 * advertising data. This also applies to the case
2222 * where BR/EDR was toggled during the AUTO_OFF phase. 2221 * where BR/EDR was toggled during the AUTO_OFF phase.
2223 */ 2222 */
2224 if (hci_dev_test_flag(hdev, HCI_LE_ENABLED) && 2223 if (hci_dev_test_flag(hdev, HCI_ADVERTISING) ||
2225 (hci_dev_test_flag(hdev, HCI_ADVERTISING) || 2224 list_empty(&hdev->adv_instances)) {
2226 list_empty(&hdev->adv_instances))) { 2225 __hci_req_update_adv_data(req, 0x00);
2227 __hci_req_update_adv_data(req, HCI_ADV_CURRENT); 2226 __hci_req_update_scan_rsp_data(req, 0x00);
2228 __hci_req_update_scan_rsp_data(req, HCI_ADV_CURRENT); 2227
2229 } 2228 if (hci_dev_test_flag(hdev, HCI_ADVERTISING))
2229 __hci_req_enable_advertising(req);
2230 } else if (!list_empty(&hdev->adv_instances)) {
2231 struct adv_info *adv_instance;
2230 2232
2231 if (hdev->cur_adv_instance == 0x00 &&
2232 !list_empty(&hdev->adv_instances)) {
2233 adv_instance = list_first_entry(&hdev->adv_instances, 2233 adv_instance = list_first_entry(&hdev->adv_instances,
2234 struct adv_info, list); 2234 struct adv_info, list);
2235 hdev->cur_adv_instance = adv_instance->instance;
2236 }
2237
2238 if (hci_dev_test_flag(hdev, HCI_ADVERTISING))
2239 __hci_req_enable_advertising(req);
2240 else if (!list_empty(&hdev->adv_instances) &&
2241 hdev->cur_adv_instance)
2242 __hci_req_schedule_adv_instance(req, 2235 __hci_req_schedule_adv_instance(req,
2243 hdev->cur_adv_instance, 2236 adv_instance->instance,
2244 true); 2237 true);
2238 }
2245 } 2239 }
2246 2240
2247 link_sec = hci_dev_test_flag(hdev, HCI_LINK_SECURITY); 2241 link_sec = hci_dev_test_flag(hdev, HCI_LINK_SECURITY);