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.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index e44d34734834..76dcc3f14cea 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -767,10 +767,30 @@ static bool scan_use_rpa(struct hci_dev *hdev)
767 return hci_dev_test_flag(hdev, HCI_PRIVACY); 767 return hci_dev_test_flag(hdev, HCI_PRIVACY);
768} 768}
769 769
770void hci_req_add_le_passive_scan(struct hci_request *req) 770static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
771 u16 window, u8 own_addr_type, u8 filter_policy)
771{ 772{
772 struct hci_cp_le_set_scan_param param_cp; 773 struct hci_cp_le_set_scan_param param_cp;
773 struct hci_cp_le_set_scan_enable enable_cp; 774 struct hci_cp_le_set_scan_enable enable_cp;
775
776 memset(&param_cp, 0, sizeof(param_cp));
777 param_cp.type = type;
778 param_cp.interval = cpu_to_le16(interval);
779 param_cp.window = cpu_to_le16(window);
780 param_cp.own_address_type = own_addr_type;
781 param_cp.filter_policy = filter_policy;
782 hci_req_add(req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp),
783 &param_cp);
784
785 memset(&enable_cp, 0, sizeof(enable_cp));
786 enable_cp.enable = LE_SCAN_ENABLE;
787 enable_cp.filter_dup = LE_SCAN_FILTER_DUP_ENABLE;
788 hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(enable_cp),
789 &enable_cp);
790}
791
792void hci_req_add_le_passive_scan(struct hci_request *req)
793{
774 struct hci_dev *hdev = req->hdev; 794 struct hci_dev *hdev = req->hdev;
775 u8 own_addr_type; 795 u8 own_addr_type;
776 u8 filter_policy; 796 u8 filter_policy;
@@ -804,20 +824,8 @@ void hci_req_add_le_passive_scan(struct hci_request *req)
804 (hdev->le_features[0] & HCI_LE_EXT_SCAN_POLICY)) 824 (hdev->le_features[0] & HCI_LE_EXT_SCAN_POLICY))
805 filter_policy |= 0x02; 825 filter_policy |= 0x02;
806 826
807 memset(&param_cp, 0, sizeof(param_cp)); 827 hci_req_start_scan(req, LE_SCAN_PASSIVE, hdev->le_scan_interval,
808 param_cp.type = LE_SCAN_PASSIVE; 828 hdev->le_scan_window, own_addr_type, filter_policy);
809 param_cp.interval = cpu_to_le16(hdev->le_scan_interval);
810 param_cp.window = cpu_to_le16(hdev->le_scan_window);
811 param_cp.own_address_type = own_addr_type;
812 param_cp.filter_policy = filter_policy;
813 hci_req_add(req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp),
814 &param_cp);
815
816 memset(&enable_cp, 0, sizeof(enable_cp));
817 enable_cp.enable = LE_SCAN_ENABLE;
818 enable_cp.filter_dup = LE_SCAN_FILTER_DUP_ENABLE;
819 hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(enable_cp),
820 &enable_cp);
821} 829}
822 830
823static u8 get_cur_adv_instance_scan_rsp_len(struct hci_dev *hdev) 831static u8 get_cur_adv_instance_scan_rsp_len(struct hci_dev *hdev)
@@ -2010,8 +2018,6 @@ static int active_scan(struct hci_request *req, unsigned long opt)
2010{ 2018{
2011 uint16_t interval = opt; 2019 uint16_t interval = opt;
2012 struct hci_dev *hdev = req->hdev; 2020 struct hci_dev *hdev = req->hdev;
2013 struct hci_cp_le_set_scan_param param_cp;
2014 struct hci_cp_le_set_scan_enable enable_cp;
2015 u8 own_addr_type; 2021 u8 own_addr_type;
2016 int err; 2022 int err;
2017 2023
@@ -2050,22 +2056,8 @@ static int active_scan(struct hci_request *req, unsigned long opt)
2050 if (err < 0) 2056 if (err < 0)
2051 own_addr_type = ADDR_LE_DEV_PUBLIC; 2057 own_addr_type = ADDR_LE_DEV_PUBLIC;
2052 2058
2053 memset(&param_cp, 0, sizeof(param_cp)); 2059 hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, DISCOV_LE_SCAN_WIN,
2054 param_cp.type = LE_SCAN_ACTIVE; 2060 own_addr_type, 0);
2055 param_cp.interval = cpu_to_le16(interval);
2056 param_cp.window = cpu_to_le16(DISCOV_LE_SCAN_WIN);
2057 param_cp.own_address_type = own_addr_type;
2058
2059 hci_req_add(req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp),
2060 &param_cp);
2061
2062 memset(&enable_cp, 0, sizeof(enable_cp));
2063 enable_cp.enable = LE_SCAN_ENABLE;
2064 enable_cp.filter_dup = LE_SCAN_FILTER_DUP_ENABLE;
2065
2066 hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(enable_cp),
2067 &enable_cp);
2068
2069 return 0; 2061 return 0;
2070} 2062}
2071 2063