diff options
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r-- | net/bluetooth/hci_core.c | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 93f92a085506..5dcacf9607e4 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -1373,8 +1373,6 @@ static void hci_init1_req(struct hci_request *req, unsigned long opt) | |||
1373 | 1373 | ||
1374 | static void bredr_setup(struct hci_request *req) | 1374 | static void bredr_setup(struct hci_request *req) |
1375 | { | 1375 | { |
1376 | struct hci_dev *hdev = req->hdev; | ||
1377 | |||
1378 | __le16 param; | 1376 | __le16 param; |
1379 | __u8 flt_type; | 1377 | __u8 flt_type; |
1380 | 1378 | ||
@@ -1403,14 +1401,6 @@ static void bredr_setup(struct hci_request *req) | |||
1403 | /* Connection accept timeout ~20 secs */ | 1401 | /* Connection accept timeout ~20 secs */ |
1404 | param = cpu_to_le16(0x7d00); | 1402 | param = cpu_to_le16(0x7d00); |
1405 | hci_req_add(req, HCI_OP_WRITE_CA_TIMEOUT, 2, ¶m); | 1403 | hci_req_add(req, HCI_OP_WRITE_CA_TIMEOUT, 2, ¶m); |
1406 | |||
1407 | /* AVM Berlin (31), aka "BlueFRITZ!", reports version 1.2, | ||
1408 | * but it does not support page scan related HCI commands. | ||
1409 | */ | ||
1410 | if (hdev->manufacturer != 31 && hdev->hci_ver > BLUETOOTH_VER_1_1) { | ||
1411 | hci_req_add(req, HCI_OP_READ_PAGE_SCAN_ACTIVITY, 0, NULL); | ||
1412 | hci_req_add(req, HCI_OP_READ_PAGE_SCAN_TYPE, 0, NULL); | ||
1413 | } | ||
1414 | } | 1404 | } |
1415 | 1405 | ||
1416 | static void le_setup(struct hci_request *req) | 1406 | static void le_setup(struct hci_request *req) |
@@ -1718,6 +1708,16 @@ static void hci_init3_req(struct hci_request *req, unsigned long opt) | |||
1718 | if (hdev->commands[5] & 0x10) | 1708 | if (hdev->commands[5] & 0x10) |
1719 | hci_setup_link_policy(req); | 1709 | hci_setup_link_policy(req); |
1720 | 1710 | ||
1711 | if (hdev->commands[8] & 0x01) | ||
1712 | hci_req_add(req, HCI_OP_READ_PAGE_SCAN_ACTIVITY, 0, NULL); | ||
1713 | |||
1714 | /* Some older Broadcom based Bluetooth 1.2 controllers do not | ||
1715 | * support the Read Page Scan Type command. Check support for | ||
1716 | * this command in the bit mask of supported commands. | ||
1717 | */ | ||
1718 | if (hdev->commands[13] & 0x01) | ||
1719 | hci_req_add(req, HCI_OP_READ_PAGE_SCAN_TYPE, 0, NULL); | ||
1720 | |||
1721 | if (lmp_le_capable(hdev)) { | 1721 | if (lmp_le_capable(hdev)) { |
1722 | u8 events[8]; | 1722 | u8 events[8]; |
1723 | 1723 | ||
@@ -2634,6 +2634,12 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
2634 | drain_workqueue(hdev->workqueue); | 2634 | drain_workqueue(hdev->workqueue); |
2635 | 2635 | ||
2636 | hci_dev_lock(hdev); | 2636 | hci_dev_lock(hdev); |
2637 | |||
2638 | if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) { | ||
2639 | if (hdev->dev_type == HCI_BREDR) | ||
2640 | mgmt_powered(hdev, 0); | ||
2641 | } | ||
2642 | |||
2637 | hci_inquiry_cache_flush(hdev); | 2643 | hci_inquiry_cache_flush(hdev); |
2638 | hci_pend_le_actions_clear(hdev); | 2644 | hci_pend_le_actions_clear(hdev); |
2639 | hci_conn_hash_flush(hdev); | 2645 | hci_conn_hash_flush(hdev); |
@@ -2681,14 +2687,6 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
2681 | hdev->flags &= BIT(HCI_RAW); | 2687 | hdev->flags &= BIT(HCI_RAW); |
2682 | hdev->dev_flags &= ~HCI_PERSISTENT_MASK; | 2688 | hdev->dev_flags &= ~HCI_PERSISTENT_MASK; |
2683 | 2689 | ||
2684 | if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) { | ||
2685 | if (hdev->dev_type == HCI_BREDR) { | ||
2686 | hci_dev_lock(hdev); | ||
2687 | mgmt_powered(hdev, 0); | ||
2688 | hci_dev_unlock(hdev); | ||
2689 | } | ||
2690 | } | ||
2691 | |||
2692 | /* Controller radio is available but is currently powered down */ | 2690 | /* Controller radio is available but is currently powered down */ |
2693 | hdev->amp_status = AMP_STATUS_POWERED_DOWN; | 2691 | hdev->amp_status = AMP_STATUS_POWERED_DOWN; |
2694 | 2692 | ||
@@ -3083,7 +3081,9 @@ static void hci_power_on(struct work_struct *work) | |||
3083 | 3081 | ||
3084 | err = hci_dev_do_open(hdev); | 3082 | err = hci_dev_do_open(hdev); |
3085 | if (err < 0) { | 3083 | if (err < 0) { |
3084 | hci_dev_lock(hdev); | ||
3086 | mgmt_set_powered_failed(hdev, err); | 3085 | mgmt_set_powered_failed(hdev, err); |
3086 | hci_dev_unlock(hdev); | ||
3087 | return; | 3087 | return; |
3088 | } | 3088 | } |
3089 | 3089 | ||
@@ -3959,17 +3959,29 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, | |||
3959 | } | 3959 | } |
3960 | 3960 | ||
3961 | /* In case of required privacy without resolvable private address, | 3961 | /* In case of required privacy without resolvable private address, |
3962 | * use an unresolvable private address. This is useful for active | 3962 | * use an non-resolvable private address. This is useful for active |
3963 | * scanning and non-connectable advertising. | 3963 | * scanning and non-connectable advertising. |
3964 | */ | 3964 | */ |
3965 | if (require_privacy) { | 3965 | if (require_privacy) { |
3966 | bdaddr_t urpa; | 3966 | bdaddr_t nrpa; |
3967 | |||
3968 | while (true) { | ||
3969 | /* The non-resolvable private address is generated | ||
3970 | * from random six bytes with the two most significant | ||
3971 | * bits cleared. | ||
3972 | */ | ||
3973 | get_random_bytes(&nrpa, 6); | ||
3974 | nrpa.b[5] &= 0x3f; | ||
3967 | 3975 | ||
3968 | get_random_bytes(&urpa, 6); | 3976 | /* The non-resolvable private address shall not be |
3969 | urpa.b[5] &= 0x3f; /* Clear two most significant bits */ | 3977 | * equal to the public address. |
3978 | */ | ||
3979 | if (bacmp(&hdev->bdaddr, &nrpa)) | ||
3980 | break; | ||
3981 | } | ||
3970 | 3982 | ||
3971 | *own_addr_type = ADDR_LE_DEV_RANDOM; | 3983 | *own_addr_type = ADDR_LE_DEV_RANDOM; |
3972 | set_random_addr(req, &urpa); | 3984 | set_random_addr(req, &nrpa); |
3973 | return 0; | 3985 | return 0; |
3974 | } | 3986 | } |
3975 | 3987 | ||
@@ -5625,7 +5637,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) | |||
5625 | u8 filter_policy; | 5637 | u8 filter_policy; |
5626 | 5638 | ||
5627 | /* Set require_privacy to false since no SCAN_REQ are send | 5639 | /* Set require_privacy to false since no SCAN_REQ are send |
5628 | * during passive scanning. Not using an unresolvable address | 5640 | * during passive scanning. Not using an non-resolvable address |
5629 | * here is important so that peer devices using direct | 5641 | * here is important so that peer devices using direct |
5630 | * advertising with our address will be correctly reported | 5642 | * advertising with our address will be correctly reported |
5631 | * by the controller. | 5643 | * by the controller. |