Skip to content

Commit ec2904c

Browse files
bgixVudentz
authored andcommitted
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 <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 38f230f commit ec2904c

File tree

3 files changed

+0
-290
lines changed

3 files changed

+0
-290
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ struct hci_dev {
517517
struct work_struct cmd_work;
518518
struct work_struct tx_work;
519519

520-
struct work_struct discov_update;
521520
struct work_struct scan_update;
522521
struct delayed_work le_scan_disable;
523522
struct delayed_work le_scan_restart;

net/bluetooth/hci_request.c

Lines changed: 0 additions & 287 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,146 +2227,6 @@ static void le_scan_restart_work(struct work_struct *work)
22272227
hci_dev_unlock(hdev);
22282228
}
22292229

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-
23702230
bool hci_req_stop_discovery(struct hci_request *req)
23712231
{
23722232
struct hci_dev *hdev = req->hdev;
@@ -2462,42 +2322,6 @@ int hci_req_configure_datapath(struct hci_dev *hdev, struct bt_codec *codec)
24622322
return err;
24632323
}
24642324

2465-
static int stop_discovery(struct hci_request *req, unsigned long opt)
2466-
{
2467-
hci_dev_lock(req->hdev);
2468-
hci_req_stop_discovery(req);
2469-
hci_dev_unlock(req->hdev);
2470-
2471-
return 0;
2472-
}
2473-
2474-
static void discov_update(struct work_struct *work)
2475-
{
2476-
struct hci_dev *hdev = container_of(work, struct hci_dev,
2477-
discov_update);
2478-
u8 status = 0;
2479-
2480-
switch (hdev->discovery.state) {
2481-
case DISCOVERY_STARTING:
2482-
start_discovery(hdev, &status);
2483-
mgmt_start_discovery_complete(hdev, status);
2484-
if (status)
2485-
hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
2486-
else
2487-
hci_discovery_set_state(hdev, DISCOVERY_FINDING);
2488-
break;
2489-
case DISCOVERY_STOPPING:
2490-
hci_req_sync(hdev, stop_discovery, 0, HCI_CMD_TIMEOUT, &status);
2491-
mgmt_stop_discovery_complete(hdev, status);
2492-
if (!status)
2493-
hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
2494-
break;
2495-
case DISCOVERY_STOPPED:
2496-
default:
2497-
return;
2498-
}
2499-
}
2500-
25012325
static void discov_off(struct work_struct *work)
25022326
{
25032327
struct hci_dev *hdev = container_of(work, struct hci_dev,
@@ -2522,118 +2346,8 @@ static void discov_off(struct work_struct *work)
25222346
mgmt_new_settings(hdev);
25232347
}
25242348

2525-
static int powered_update_hci(struct hci_request *req, unsigned long opt)
2526-
{
2527-
struct hci_dev *hdev = req->hdev;
2528-
u8 link_sec;
2529-
2530-
hci_dev_lock(hdev);
2531-
2532-
if (hci_dev_test_flag(hdev, HCI_SSP_ENABLED) &&
2533-
!lmp_host_ssp_capable(hdev)) {
2534-
u8 mode = 0x01;
2535-
2536-
hci_req_add(req, HCI_OP_WRITE_SSP_MODE, sizeof(mode), &mode);
2537-
2538-
if (bredr_sc_enabled(hdev) && !lmp_host_sc_capable(hdev)) {
2539-
u8 support = 0x01;
2540-
2541-
hci_req_add(req, HCI_OP_WRITE_SC_SUPPORT,
2542-
sizeof(support), &support);
2543-
}
2544-
}
2545-
2546-
if (hci_dev_test_flag(hdev, HCI_LE_ENABLED) &&
2547-
lmp_bredr_capable(hdev)) {
2548-
struct hci_cp_write_le_host_supported cp;
2549-
2550-
cp.le = 0x01;
2551-
cp.simul = 0x00;
2552-
2553-
/* Check first if we already have the right
2554-
* host state (host features set)
2555-
*/
2556-
if (cp.le != lmp_host_le_capable(hdev) ||
2557-
cp.simul != lmp_host_le_br_capable(hdev))
2558-
hci_req_add(req, HCI_OP_WRITE_LE_HOST_SUPPORTED,
2559-
sizeof(cp), &cp);
2560-
}
2561-
2562-
if (hci_dev_test_flag(hdev, HCI_LE_ENABLED)) {
2563-
/* Make sure the controller has a good default for
2564-
* advertising data. This also applies to the case
2565-
* where BR/EDR was toggled during the AUTO_OFF phase.
2566-
*/
2567-
if (hci_dev_test_flag(hdev, HCI_ADVERTISING) ||
2568-
list_empty(&hdev->adv_instances)) {
2569-
int err;
2570-
2571-
if (ext_adv_capable(hdev)) {
2572-
err = __hci_req_setup_ext_adv_instance(req,
2573-
0x00);
2574-
if (!err)
2575-
__hci_req_update_scan_rsp_data(req,
2576-
0x00);
2577-
} else {
2578-
err = 0;
2579-
__hci_req_update_adv_data(req, 0x00);
2580-
__hci_req_update_scan_rsp_data(req, 0x00);
2581-
}
2582-
2583-
if (hci_dev_test_flag(hdev, HCI_ADVERTISING)) {
2584-
if (!ext_adv_capable(hdev))
2585-
__hci_req_enable_advertising(req);
2586-
else if (!err)
2587-
__hci_req_enable_ext_advertising(req,
2588-
0x00);
2589-
}
2590-
} else if (!list_empty(&hdev->adv_instances)) {
2591-
struct adv_info *adv_instance;
2592-
2593-
adv_instance = list_first_entry(&hdev->adv_instances,
2594-
struct adv_info, list);
2595-
__hci_req_schedule_adv_instance(req,
2596-
adv_instance->instance,
2597-
true);
2598-
}
2599-
}
2600-
2601-
link_sec = hci_dev_test_flag(hdev, HCI_LINK_SECURITY);
2602-
if (link_sec != test_bit(HCI_AUTH, &hdev->flags))
2603-
hci_req_add(req, HCI_OP_WRITE_AUTH_ENABLE,
2604-
sizeof(link_sec), &link_sec);
2605-
2606-
if (lmp_bredr_capable(hdev)) {
2607-
if (hci_dev_test_flag(hdev, HCI_FAST_CONNECTABLE))
2608-
__hci_req_write_fast_connectable(req, true);
2609-
else
2610-
__hci_req_write_fast_connectable(req, false);
2611-
__hci_req_update_scan(req);
2612-
__hci_req_update_class(req);
2613-
__hci_req_update_name(req);
2614-
__hci_req_update_eir(req);
2615-
}
2616-
2617-
hci_dev_unlock(hdev);
2618-
return 0;
2619-
}
2620-
2621-
int __hci_req_hci_power_on(struct hci_dev *hdev)
2622-
{
2623-
/* Register the available SMP channels (BR/EDR and LE) only when
2624-
* successfully powering on the controller. This late
2625-
* registration is required so that LE SMP can clearly decide if
2626-
* the public address or static address is used.
2627-
*/
2628-
smp_register(hdev);
2629-
2630-
return __hci_req_sync(hdev, powered_update_hci, 0, HCI_CMD_TIMEOUT,
2631-
NULL);
2632-
}
2633-
26342349
void hci_request_setup(struct hci_dev *hdev)
26352350
{
2636-
INIT_WORK(&hdev->discov_update, discov_update);
26372351
INIT_WORK(&hdev->scan_update, scan_update_work);
26382352
INIT_DELAYED_WORK(&hdev->discov_off, discov_off);
26392353
INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work);
@@ -2646,7 +2360,6 @@ void hci_request_cancel_all(struct hci_dev *hdev)
26462360
{
26472361
__hci_cmd_sync_cancel(hdev, ENODEV);
26482362

2649-
cancel_work_sync(&hdev->discov_update);
26502363
cancel_work_sync(&hdev->scan_update);
26512364
cancel_delayed_work_sync(&hdev->discov_off);
26522365
cancel_delayed_work_sync(&hdev->le_scan_disable);

net/bluetooth/hci_request.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req,
6868
struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen,
6969
const void *param);
7070

71-
int __hci_req_hci_power_on(struct hci_dev *hdev);
72-
7371
void __hci_req_write_fast_connectable(struct hci_request *req, bool enable);
7472
void __hci_req_update_name(struct hci_request *req);
7573
void __hci_req_update_eir(struct hci_request *req);

0 commit comments

Comments
 (0)