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: Remove dead code from hci_request.c

The discov_update work queue is no longer used as a result
of the hci_sync rework.

The __hci_req_hci_power_on() function is no longer referenced in the
code as a result of the hci_sync rework.

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
ec2904c2 38f230f1

-290
-1
include/net/bluetooth/hci_core.h
··· 517 517 struct work_struct cmd_work; 518 518 struct work_struct tx_work; 519 519 520 - struct work_struct discov_update; 521 520 struct work_struct scan_update; 522 521 struct delayed_work le_scan_disable; 523 522 struct delayed_work le_scan_restart;
-287
net/bluetooth/hci_request.c
··· 2227 2227 hci_dev_unlock(hdev); 2228 2228 } 2229 2229 2230 - static int active_scan(struct hci_request *req, unsigned long opt) 2231 - { 2232 - uint16_t interval = opt; 2233 - struct hci_dev *hdev = req->hdev; 2234 - u8 own_addr_type; 2235 - /* Accept list is not used for discovery */ 2236 - u8 filter_policy = 0x00; 2237 - /* Default is to enable duplicates filter */ 2238 - u8 filter_dup = LE_SCAN_FILTER_DUP_ENABLE; 2239 - /* Discovery doesn't require controller address resolution */ 2240 - bool addr_resolv = false; 2241 - int err; 2242 - 2243 - bt_dev_dbg(hdev, ""); 2244 - 2245 - /* If controller is scanning, it means the background scanning is 2246 - * running. Thus, we should temporarily stop it in order to set the 2247 - * discovery scanning parameters. 2248 - */ 2249 - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { 2250 - hci_req_add_le_scan_disable(req, false); 2251 - cancel_interleave_scan(hdev); 2252 - } 2253 - 2254 - /* All active scans will be done with either a resolvable private 2255 - * address (when privacy feature has been enabled) or non-resolvable 2256 - * private address. 2257 - */ 2258 - err = hci_update_random_address(req, true, scan_use_rpa(hdev), 2259 - &own_addr_type); 2260 - if (err < 0) 2261 - own_addr_type = ADDR_LE_DEV_PUBLIC; 2262 - 2263 - hci_dev_lock(hdev); 2264 - if (hci_is_adv_monitoring(hdev)) { 2265 - /* Duplicate filter should be disabled when some advertisement 2266 - * monitor is activated, otherwise AdvMon can only receive one 2267 - * advertisement for one peer(*) during active scanning, and 2268 - * might report loss to these peers. 2269 - * 2270 - * Note that different controllers have different meanings of 2271 - * |duplicate|. Some of them consider packets with the same 2272 - * address as duplicate, and others consider packets with the 2273 - * same address and the same RSSI as duplicate. Although in the 2274 - * latter case we don't need to disable duplicate filter, but 2275 - * it is common to have active scanning for a short period of 2276 - * time, the power impact should be neglectable. 2277 - */ 2278 - filter_dup = LE_SCAN_FILTER_DUP_DISABLE; 2279 - } 2280 - hci_dev_unlock(hdev); 2281 - 2282 - hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, 2283 - hdev->le_scan_window_discovery, own_addr_type, 2284 - filter_policy, filter_dup, addr_resolv); 2285 - return 0; 2286 - } 2287 - 2288 - static int interleaved_discov(struct hci_request *req, unsigned long opt) 2289 - { 2290 - int err; 2291 - 2292 - bt_dev_dbg(req->hdev, ""); 2293 - 2294 - err = active_scan(req, opt); 2295 - if (err) 2296 - return err; 2297 - 2298 - return bredr_inquiry(req, DISCOV_BREDR_INQUIRY_LEN); 2299 - } 2300 - 2301 - static void start_discovery(struct hci_dev *hdev, u8 *status) 2302 - { 2303 - unsigned long timeout; 2304 - 2305 - bt_dev_dbg(hdev, "type %u", hdev->discovery.type); 2306 - 2307 - switch (hdev->discovery.type) { 2308 - case DISCOV_TYPE_BREDR: 2309 - if (!hci_dev_test_flag(hdev, HCI_INQUIRY)) 2310 - hci_req_sync(hdev, bredr_inquiry, 2311 - DISCOV_BREDR_INQUIRY_LEN, HCI_CMD_TIMEOUT, 2312 - status); 2313 - return; 2314 - case DISCOV_TYPE_INTERLEAVED: 2315 - /* When running simultaneous discovery, the LE scanning time 2316 - * should occupy the whole discovery time sine BR/EDR inquiry 2317 - * and LE scanning are scheduled by the controller. 2318 - * 2319 - * For interleaving discovery in comparison, BR/EDR inquiry 2320 - * and LE scanning are done sequentially with separate 2321 - * timeouts. 2322 - */ 2323 - if (test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, 2324 - &hdev->quirks)) { 2325 - timeout = msecs_to_jiffies(DISCOV_LE_TIMEOUT); 2326 - /* During simultaneous discovery, we double LE scan 2327 - * interval. We must leave some time for the controller 2328 - * to do BR/EDR inquiry. 2329 - */ 2330 - hci_req_sync(hdev, interleaved_discov, 2331 - hdev->le_scan_int_discovery * 2, HCI_CMD_TIMEOUT, 2332 - status); 2333 - break; 2334 - } 2335 - 2336 - timeout = msecs_to_jiffies(hdev->discov_interleaved_timeout); 2337 - hci_req_sync(hdev, active_scan, hdev->le_scan_int_discovery, 2338 - HCI_CMD_TIMEOUT, status); 2339 - break; 2340 - case DISCOV_TYPE_LE: 2341 - timeout = msecs_to_jiffies(DISCOV_LE_TIMEOUT); 2342 - hci_req_sync(hdev, active_scan, hdev->le_scan_int_discovery, 2343 - HCI_CMD_TIMEOUT, status); 2344 - break; 2345 - default: 2346 - *status = HCI_ERROR_UNSPECIFIED; 2347 - return; 2348 - } 2349 - 2350 - if (*status) 2351 - return; 2352 - 2353 - bt_dev_dbg(hdev, "timeout %u ms", jiffies_to_msecs(timeout)); 2354 - 2355 - /* When service discovery is used and the controller has a 2356 - * strict duplicate filter, it is important to remember the 2357 - * start and duration of the scan. This is required for 2358 - * restarting scanning during the discovery phase. 2359 - */ 2360 - if (test_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks) && 2361 - hdev->discovery.result_filtering) { 2362 - hdev->discovery.scan_start = jiffies; 2363 - hdev->discovery.scan_duration = timeout; 2364 - } 2365 - 2366 - queue_delayed_work(hdev->req_workqueue, &hdev->le_scan_disable, 2367 - timeout); 2368 - } 2369 - 2370 2230 bool hci_req_stop_discovery(struct hci_request *req) 2371 2231 { 2372 2232 struct hci_dev *hdev = req->hdev; ··· 2322 2462 return err; 2323 2463 } 2324 2464 2325 - static int stop_discovery(struct hci_request *req, unsigned long opt) 2326 - { 2327 - hci_dev_lock(req->hdev); 2328 - hci_req_stop_discovery(req); 2329 - hci_dev_unlock(req->hdev); 2330 - 2331 - return 0; 2332 - } 2333 - 2334 - static void discov_update(struct work_struct *work) 2335 - { 2336 - struct hci_dev *hdev = container_of(work, struct hci_dev, 2337 - discov_update); 2338 - u8 status = 0; 2339 - 2340 - switch (hdev->discovery.state) { 2341 - case DISCOVERY_STARTING: 2342 - start_discovery(hdev, &status); 2343 - mgmt_start_discovery_complete(hdev, status); 2344 - if (status) 2345 - hci_discovery_set_state(hdev, DISCOVERY_STOPPED); 2346 - else 2347 - hci_discovery_set_state(hdev, DISCOVERY_FINDING); 2348 - break; 2349 - case DISCOVERY_STOPPING: 2350 - hci_req_sync(hdev, stop_discovery, 0, HCI_CMD_TIMEOUT, &status); 2351 - mgmt_stop_discovery_complete(hdev, status); 2352 - if (!status) 2353 - hci_discovery_set_state(hdev, DISCOVERY_STOPPED); 2354 - break; 2355 - case DISCOVERY_STOPPED: 2356 - default: 2357 - return; 2358 - } 2359 - } 2360 - 2361 2465 static void discov_off(struct work_struct *work) 2362 2466 { 2363 2467 struct hci_dev *hdev = container_of(work, struct hci_dev, ··· 2346 2522 mgmt_new_settings(hdev); 2347 2523 } 2348 2524 2349 - static int powered_update_hci(struct hci_request *req, unsigned long opt) 2350 - { 2351 - struct hci_dev *hdev = req->hdev; 2352 - u8 link_sec; 2353 - 2354 - hci_dev_lock(hdev); 2355 - 2356 - if (hci_dev_test_flag(hdev, HCI_SSP_ENABLED) && 2357 - !lmp_host_ssp_capable(hdev)) { 2358 - u8 mode = 0x01; 2359 - 2360 - hci_req_add(req, HCI_OP_WRITE_SSP_MODE, sizeof(mode), &mode); 2361 - 2362 - if (bredr_sc_enabled(hdev) && !lmp_host_sc_capable(hdev)) { 2363 - u8 support = 0x01; 2364 - 2365 - hci_req_add(req, HCI_OP_WRITE_SC_SUPPORT, 2366 - sizeof(support), &support); 2367 - } 2368 - } 2369 - 2370 - if (hci_dev_test_flag(hdev, HCI_LE_ENABLED) && 2371 - lmp_bredr_capable(hdev)) { 2372 - struct hci_cp_write_le_host_supported cp; 2373 - 2374 - cp.le = 0x01; 2375 - cp.simul = 0x00; 2376 - 2377 - /* Check first if we already have the right 2378 - * host state (host features set) 2379 - */ 2380 - if (cp.le != lmp_host_le_capable(hdev) || 2381 - cp.simul != lmp_host_le_br_capable(hdev)) 2382 - hci_req_add(req, HCI_OP_WRITE_LE_HOST_SUPPORTED, 2383 - sizeof(cp), &cp); 2384 - } 2385 - 2386 - if (hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { 2387 - /* Make sure the controller has a good default for 2388 - * advertising data. This also applies to the case 2389 - * where BR/EDR was toggled during the AUTO_OFF phase. 2390 - */ 2391 - if (hci_dev_test_flag(hdev, HCI_ADVERTISING) || 2392 - list_empty(&hdev->adv_instances)) { 2393 - int err; 2394 - 2395 - if (ext_adv_capable(hdev)) { 2396 - err = __hci_req_setup_ext_adv_instance(req, 2397 - 0x00); 2398 - if (!err) 2399 - __hci_req_update_scan_rsp_data(req, 2400 - 0x00); 2401 - } else { 2402 - err = 0; 2403 - __hci_req_update_adv_data(req, 0x00); 2404 - __hci_req_update_scan_rsp_data(req, 0x00); 2405 - } 2406 - 2407 - if (hci_dev_test_flag(hdev, HCI_ADVERTISING)) { 2408 - if (!ext_adv_capable(hdev)) 2409 - __hci_req_enable_advertising(req); 2410 - else if (!err) 2411 - __hci_req_enable_ext_advertising(req, 2412 - 0x00); 2413 - } 2414 - } else if (!list_empty(&hdev->adv_instances)) { 2415 - struct adv_info *adv_instance; 2416 - 2417 - adv_instance = list_first_entry(&hdev->adv_instances, 2418 - struct adv_info, list); 2419 - __hci_req_schedule_adv_instance(req, 2420 - adv_instance->instance, 2421 - true); 2422 - } 2423 - } 2424 - 2425 - link_sec = hci_dev_test_flag(hdev, HCI_LINK_SECURITY); 2426 - if (link_sec != test_bit(HCI_AUTH, &hdev->flags)) 2427 - hci_req_add(req, HCI_OP_WRITE_AUTH_ENABLE, 2428 - sizeof(link_sec), &link_sec); 2429 - 2430 - if (lmp_bredr_capable(hdev)) { 2431 - if (hci_dev_test_flag(hdev, HCI_FAST_CONNECTABLE)) 2432 - __hci_req_write_fast_connectable(req, true); 2433 - else 2434 - __hci_req_write_fast_connectable(req, false); 2435 - __hci_req_update_scan(req); 2436 - __hci_req_update_class(req); 2437 - __hci_req_update_name(req); 2438 - __hci_req_update_eir(req); 2439 - } 2440 - 2441 - hci_dev_unlock(hdev); 2442 - return 0; 2443 - } 2444 - 2445 - int __hci_req_hci_power_on(struct hci_dev *hdev) 2446 - { 2447 - /* Register the available SMP channels (BR/EDR and LE) only when 2448 - * successfully powering on the controller. This late 2449 - * registration is required so that LE SMP can clearly decide if 2450 - * the public address or static address is used. 2451 - */ 2452 - smp_register(hdev); 2453 - 2454 - return __hci_req_sync(hdev, powered_update_hci, 0, HCI_CMD_TIMEOUT, 2455 - NULL); 2456 - } 2457 - 2458 2525 void hci_request_setup(struct hci_dev *hdev) 2459 2526 { 2460 - INIT_WORK(&hdev->discov_update, discov_update); 2461 2527 INIT_WORK(&hdev->scan_update, scan_update_work); 2462 2528 INIT_DELAYED_WORK(&hdev->discov_off, discov_off); 2463 2529 INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); ··· 2360 2646 { 2361 2647 __hci_cmd_sync_cancel(hdev, ENODEV); 2362 2648 2363 - cancel_work_sync(&hdev->discov_update); 2364 2649 cancel_work_sync(&hdev->scan_update); 2365 2650 cancel_delayed_work_sync(&hdev->discov_off); 2366 2651 cancel_delayed_work_sync(&hdev->le_scan_disable);
-2
net/bluetooth/hci_request.h
··· 68 68 struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen, 69 69 const void *param); 70 70 71 - int __hci_req_hci_power_on(struct hci_dev *hdev); 72 - 73 71 void __hci_req_write_fast_connectable(struct hci_request *req, bool enable); 74 72 void __hci_req_update_name(struct hci_request *req); 75 73 void __hci_req_update_eir(struct hci_request *req);