aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_request.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/hci_request.c')
-rw-r--r--net/bluetooth/hci_request.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index b59f92c6df0c..d6025d6e6d59 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -34,7 +34,8 @@ void hci_req_init(struct hci_request *req, struct hci_dev *hdev)
34 req->err = 0; 34 req->err = 0;
35} 35}
36 36
37int hci_req_run(struct hci_request *req, hci_req_complete_t complete) 37static int req_run(struct hci_request *req, hci_req_complete_t complete,
38 hci_req_complete_skb_t complete_skb)
38{ 39{
39 struct hci_dev *hdev = req->hdev; 40 struct hci_dev *hdev = req->hdev;
40 struct sk_buff *skb; 41 struct sk_buff *skb;
@@ -56,6 +57,7 @@ int hci_req_run(struct hci_request *req, hci_req_complete_t complete)
56 57
57 skb = skb_peek_tail(&req->cmd_q); 58 skb = skb_peek_tail(&req->cmd_q);
58 bt_cb(skb)->req.complete = complete; 59 bt_cb(skb)->req.complete = complete;
60 bt_cb(skb)->req.complete_skb = complete_skb;
59 61
60 spin_lock_irqsave(&hdev->cmd_q.lock, flags); 62 spin_lock_irqsave(&hdev->cmd_q.lock, flags);
61 skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q); 63 skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q);
@@ -66,6 +68,16 @@ int hci_req_run(struct hci_request *req, hci_req_complete_t complete)
66 return 0; 68 return 0;
67} 69}
68 70
71int hci_req_run(struct hci_request *req, hci_req_complete_t complete)
72{
73 return req_run(req, complete, NULL);
74}
75
76int hci_req_run_skb(struct hci_request *req, hci_req_complete_skb_t complete)
77{
78 return req_run(req, NULL, complete);
79}
80
69struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen, 81struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen,
70 const void *param) 82 const void *param)
71{ 83{
@@ -270,7 +282,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req)
270 * and 0x01 (whitelist enabled) use the new filter policies 282 * and 0x01 (whitelist enabled) use the new filter policies
271 * 0x02 (no whitelist) and 0x03 (whitelist enabled). 283 * 0x02 (no whitelist) and 0x03 (whitelist enabled).
272 */ 284 */
273 if (test_bit(HCI_PRIVACY, &hdev->dev_flags) && 285 if (hci_dev_test_flag(hdev, HCI_PRIVACY) &&
274 (hdev->le_features[0] & HCI_LE_EXT_SCAN_POLICY)) 286 (hdev->le_features[0] & HCI_LE_EXT_SCAN_POLICY))
275 filter_policy |= 0x02; 287 filter_policy |= 0x02;
276 288
@@ -304,10 +316,10 @@ static void set_random_addr(struct hci_request *req, bdaddr_t *rpa)
304 * In this kind of scenario skip the update and let the random 316 * In this kind of scenario skip the update and let the random
305 * address be updated at the next cycle. 317 * address be updated at the next cycle.
306 */ 318 */
307 if (test_bit(HCI_LE_ADV, &hdev->dev_flags) || 319 if (hci_dev_test_flag(hdev, HCI_LE_ADV) ||
308 hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT)) { 320 hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT)) {
309 BT_DBG("Deferring random address update"); 321 BT_DBG("Deferring random address update");
310 set_bit(HCI_RPA_EXPIRED, &hdev->dev_flags); 322 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED);
311 return; 323 return;
312 } 324 }
313 325
@@ -324,12 +336,12 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy,
324 * current RPA has expired or there is something else than 336 * current RPA has expired or there is something else than
325 * the current RPA in use, then generate a new one. 337 * the current RPA in use, then generate a new one.
326 */ 338 */
327 if (test_bit(HCI_PRIVACY, &hdev->dev_flags)) { 339 if (hci_dev_test_flag(hdev, HCI_PRIVACY)) {
328 int to; 340 int to;
329 341
330 *own_addr_type = ADDR_LE_DEV_RANDOM; 342 *own_addr_type = ADDR_LE_DEV_RANDOM;
331 343
332 if (!test_and_clear_bit(HCI_RPA_EXPIRED, &hdev->dev_flags) && 344 if (!hci_dev_test_and_clear_flag(hdev, HCI_RPA_EXPIRED) &&
333 !bacmp(&hdev->random_addr, &hdev->rpa)) 345 !bacmp(&hdev->random_addr, &hdev->rpa))
334 return 0; 346 return 0;
335 347
@@ -383,9 +395,9 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy,
383 * and a static address has been configured, then use that 395 * and a static address has been configured, then use that
384 * address instead of the public BR/EDR address. 396 * address instead of the public BR/EDR address.
385 */ 397 */
386 if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) || 398 if (hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR) ||
387 !bacmp(&hdev->bdaddr, BDADDR_ANY) || 399 !bacmp(&hdev->bdaddr, BDADDR_ANY) ||
388 (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) && 400 (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) &&
389 bacmp(&hdev->static_addr, BDADDR_ANY))) { 401 bacmp(&hdev->static_addr, BDADDR_ANY))) {
390 *own_addr_type = ADDR_LE_DEV_RANDOM; 402 *own_addr_type = ADDR_LE_DEV_RANDOM;
391 if (bacmp(&hdev->static_addr, &hdev->random_addr)) 403 if (bacmp(&hdev->static_addr, &hdev->random_addr))
@@ -425,7 +437,7 @@ void __hci_update_page_scan(struct hci_request *req)
425 struct hci_dev *hdev = req->hdev; 437 struct hci_dev *hdev = req->hdev;
426 u8 scan; 438 u8 scan;
427 439
428 if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) 440 if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED))
429 return; 441 return;
430 442
431 if (!hdev_is_powered(hdev)) 443 if (!hdev_is_powered(hdev))
@@ -434,7 +446,7 @@ void __hci_update_page_scan(struct hci_request *req)
434 if (mgmt_powering_down(hdev)) 446 if (mgmt_powering_down(hdev))
435 return; 447 return;
436 448
437 if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags) || 449 if (hci_dev_test_flag(hdev, HCI_CONNECTABLE) ||
438 disconnected_whitelist_entries(hdev)) 450 disconnected_whitelist_entries(hdev))
439 scan = SCAN_PAGE; 451 scan = SCAN_PAGE;
440 else 452 else
@@ -443,7 +455,7 @@ void __hci_update_page_scan(struct hci_request *req)
443 if (test_bit(HCI_PSCAN, &hdev->flags) == !!(scan & SCAN_PAGE)) 455 if (test_bit(HCI_PSCAN, &hdev->flags) == !!(scan & SCAN_PAGE))
444 return; 456 return;
445 457
446 if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) 458 if (hci_dev_test_flag(hdev, HCI_DISCOVERABLE))
447 scan |= SCAN_INQUIRY; 459 scan |= SCAN_INQUIRY;
448 460
449 hci_req_add(req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); 461 hci_req_add(req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
@@ -471,14 +483,14 @@ void __hci_update_background_scan(struct hci_request *req)
471 483
472 if (!test_bit(HCI_UP, &hdev->flags) || 484 if (!test_bit(HCI_UP, &hdev->flags) ||
473 test_bit(HCI_INIT, &hdev->flags) || 485 test_bit(HCI_INIT, &hdev->flags) ||
474 test_bit(HCI_SETUP, &hdev->dev_flags) || 486 hci_dev_test_flag(hdev, HCI_SETUP) ||
475 test_bit(HCI_CONFIG, &hdev->dev_flags) || 487 hci_dev_test_flag(hdev, HCI_CONFIG) ||
476 test_bit(HCI_AUTO_OFF, &hdev->dev_flags) || 488 hci_dev_test_flag(hdev, HCI_AUTO_OFF) ||
477 test_bit(HCI_UNREGISTER, &hdev->dev_flags)) 489 hci_dev_test_flag(hdev, HCI_UNREGISTER))
478 return; 490 return;
479 491
480 /* No point in doing scanning if LE support hasn't been enabled */ 492 /* No point in doing scanning if LE support hasn't been enabled */
481 if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) 493 if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED))
482 return; 494 return;
483 495
484 /* If discovery is active don't interfere with it */ 496 /* If discovery is active don't interfere with it */
@@ -502,7 +514,7 @@ void __hci_update_background_scan(struct hci_request *req)
502 */ 514 */
503 515
504 /* If controller is not scanning we are done. */ 516 /* If controller is not scanning we are done. */
505 if (!test_bit(HCI_LE_SCAN, &hdev->dev_flags)) 517 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN))
506 return; 518 return;
507 519
508 hci_req_add_le_scan_disable(req); 520 hci_req_add_le_scan_disable(req);
@@ -524,7 +536,7 @@ void __hci_update_background_scan(struct hci_request *req)
524 /* If controller is currently scanning, we stop it to ensure we 536 /* If controller is currently scanning, we stop it to ensure we
525 * don't miss any advertising (due to duplicates filter). 537 * don't miss any advertising (due to duplicates filter).
526 */ 538 */
527 if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) 539 if (hci_dev_test_flag(hdev, HCI_LE_SCAN))
528 hci_req_add_le_scan_disable(req); 540 hci_req_add_le_scan_disable(req);
529 541
530 hci_req_add_le_passive_scan(req); 542 hci_req_add_le_passive_scan(req);