Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: Convert delayed discov_off to hci_sync

The timed ending of Discoverability was handled in hci_requst.c, with
calls using the deprecated hci_req_add() mechanism. Converted to live
inside mgmt.c using the same delayed work queue, but with hci_sync
version of hci_update_discoverable().

Signed-off-by: Brian Gix <brian.gix@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Brian Gix and committed by
Luiz Augusto von Dentz
0ef08313 bb876725

+33 -89
-89
net/bluetooth/hci_request.c
··· 1875 1875 hci_req_add(req, HCI_OP_WRITE_CLASS_OF_DEV, sizeof(cod), cod); 1876 1876 } 1877 1877 1878 - static void write_iac(struct hci_request *req) 1879 - { 1880 - struct hci_dev *hdev = req->hdev; 1881 - struct hci_cp_write_current_iac_lap cp; 1882 - 1883 - if (!hci_dev_test_flag(hdev, HCI_DISCOVERABLE)) 1884 - return; 1885 - 1886 - if (hci_dev_test_flag(hdev, HCI_LIMITED_DISCOVERABLE)) { 1887 - /* Limited discoverable mode */ 1888 - cp.num_iac = min_t(u8, hdev->num_iac, 2); 1889 - cp.iac_lap[0] = 0x00; /* LIAC */ 1890 - cp.iac_lap[1] = 0x8b; 1891 - cp.iac_lap[2] = 0x9e; 1892 - cp.iac_lap[3] = 0x33; /* GIAC */ 1893 - cp.iac_lap[4] = 0x8b; 1894 - cp.iac_lap[5] = 0x9e; 1895 - } else { 1896 - /* General discoverable mode */ 1897 - cp.num_iac = 1; 1898 - cp.iac_lap[0] = 0x33; /* GIAC */ 1899 - cp.iac_lap[1] = 0x8b; 1900 - cp.iac_lap[2] = 0x9e; 1901 - } 1902 - 1903 - hci_req_add(req, HCI_OP_WRITE_CURRENT_IAC_LAP, 1904 - (cp.num_iac * 3) + 1, &cp); 1905 - } 1906 - 1907 - static int discoverable_update(struct hci_request *req, unsigned long opt) 1908 - { 1909 - struct hci_dev *hdev = req->hdev; 1910 - 1911 - hci_dev_lock(hdev); 1912 - 1913 - if (hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { 1914 - write_iac(req); 1915 - __hci_req_update_scan(req); 1916 - __hci_req_update_class(req); 1917 - } 1918 - 1919 - /* Advertising instances don't use the global discoverable setting, so 1920 - * only update AD if advertising was enabled using Set Advertising. 1921 - */ 1922 - if (hci_dev_test_flag(hdev, HCI_ADVERTISING)) { 1923 - __hci_req_update_adv_data(req, 0x00); 1924 - 1925 - /* Discoverable mode affects the local advertising 1926 - * address in limited privacy mode. 1927 - */ 1928 - if (hci_dev_test_flag(hdev, HCI_LIMITED_PRIVACY)) { 1929 - if (ext_adv_capable(hdev)) 1930 - __hci_req_start_ext_adv(req, 0x00); 1931 - else 1932 - __hci_req_enable_advertising(req); 1933 - } 1934 - } 1935 - 1936 - hci_dev_unlock(hdev); 1937 - 1938 - return 0; 1939 - } 1940 - 1941 1878 void __hci_abort_conn(struct hci_request *req, struct hci_conn *conn, 1942 1879 u8 reason) 1943 1880 { ··· 2244 2307 return err; 2245 2308 } 2246 2309 2247 - static void discov_off(struct work_struct *work) 2248 - { 2249 - struct hci_dev *hdev = container_of(work, struct hci_dev, 2250 - discov_off.work); 2251 - 2252 - bt_dev_dbg(hdev, ""); 2253 - 2254 - hci_dev_lock(hdev); 2255 - 2256 - /* When discoverable timeout triggers, then just make sure 2257 - * the limited discoverable flag is cleared. Even in the case 2258 - * of a timeout triggered from general discoverable, it is 2259 - * safe to unconditionally clear the flag. 2260 - */ 2261 - hci_dev_clear_flag(hdev, HCI_LIMITED_DISCOVERABLE); 2262 - hci_dev_clear_flag(hdev, HCI_DISCOVERABLE); 2263 - hdev->discov_timeout = 0; 2264 - 2265 - hci_dev_unlock(hdev); 2266 - 2267 - hci_req_sync(hdev, discoverable_update, 0, HCI_CMD_TIMEOUT, NULL); 2268 - mgmt_new_settings(hdev); 2269 - } 2270 - 2271 2310 void hci_request_setup(struct hci_dev *hdev) 2272 2311 { 2273 - INIT_DELAYED_WORK(&hdev->discov_off, discov_off); 2274 2312 INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); 2275 2313 INIT_DELAYED_WORK(&hdev->le_scan_restart, le_scan_restart_work); 2276 2314 INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); ··· 2256 2344 { 2257 2345 __hci_cmd_sync_cancel(hdev, ENODEV); 2258 2346 2259 - cancel_delayed_work_sync(&hdev->discov_off); 2260 2347 cancel_delayed_work_sync(&hdev->le_scan_disable); 2261 2348 cancel_delayed_work_sync(&hdev->le_scan_restart); 2262 2349
+33
net/bluetooth/mgmt.c
··· 1023 1023 hci_cmd_sync_queue(hdev, rpa_expired_sync, NULL, NULL); 1024 1024 } 1025 1025 1026 + static void discov_off(struct work_struct *work) 1027 + { 1028 + struct hci_dev *hdev = container_of(work, struct hci_dev, 1029 + discov_off.work); 1030 + 1031 + bt_dev_dbg(hdev, ""); 1032 + 1033 + hci_dev_lock(hdev); 1034 + 1035 + /* When discoverable timeout triggers, then just make sure 1036 + * the limited discoverable flag is cleared. Even in the case 1037 + * of a timeout triggered from general discoverable, it is 1038 + * safe to unconditionally clear the flag. 1039 + */ 1040 + hci_dev_clear_flag(hdev, HCI_LIMITED_DISCOVERABLE); 1041 + hci_dev_clear_flag(hdev, HCI_DISCOVERABLE); 1042 + hdev->discov_timeout = 0; 1043 + 1044 + hci_update_discoverable(hdev); 1045 + 1046 + mgmt_new_settings(hdev); 1047 + 1048 + hci_dev_unlock(hdev); 1049 + } 1050 + 1026 1051 static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev) 1027 1052 { 1028 1053 if (hci_dev_test_and_set_flag(hdev, HCI_MGMT)) 1029 1054 return; 1030 1055 1056 + BT_INFO("MGMT ver %d.%d", MGMT_VERSION, MGMT_REVISION); 1057 + 1058 + INIT_DELAYED_WORK(&hdev->discov_off, discov_off); 1031 1059 INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); 1032 1060 INIT_DELAYED_WORK(&hdev->rpa_expired, rpa_expired); 1033 1061 ··· 8867 8839 8868 8840 mgmt_index_event(MGMT_EV_EXT_INDEX_REMOVED, hdev, &ev, sizeof(ev), 8869 8841 HCI_MGMT_EXT_INDEX_EVENTS); 8842 + 8843 + /* Cancel any remaining timed work */ 8844 + cancel_delayed_work_sync(&hdev->discov_off); 8845 + cancel_delayed_work_sync(&hdev->service_cache); 8846 + cancel_delayed_work_sync(&hdev->rpa_expired); 8870 8847 } 8871 8848 8872 8849 void mgmt_power_on(struct hci_dev *hdev, int err)