Skip to content

Commit 8bedf13

Browse files
committed
Bluetooth: hci_sync: Move handling of interleave_scan
This moves handling of interleave_scan work to hci_sync.c since hci_request.c is deprecated. Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 176cbec commit 8bedf13

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

net/bluetooth/hci_core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,7 +2552,6 @@ struct hci_dev *hci_alloc_dev_priv(int sizeof_priv)
25522552
INIT_DELAYED_WORK(&hdev->ncmd_timer, hci_ncmd_timeout);
25532553

25542554
hci_devcd_setup(hdev);
2555-
hci_request_setup(hdev);
25562555

25572556
hci_init_sysfs(hdev);
25582557
discovery_init(hdev);
@@ -4074,7 +4073,7 @@ static void hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb)
40744073
return;
40754074
}
40764075

4077-
if (hci_req_status_pend(hdev) &&
4076+
if (hdev->req_status == HCI_REQ_PEND &&
40784077
!hci_dev_test_and_set_flag(hdev, HCI_CMD_PENDING)) {
40794078
kfree_skb(hdev->req_skb);
40804079
hdev->req_skb = skb_clone(hdev->sent_cmd, GFP_KERNEL);

net/bluetooth/hci_sync.c

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,53 @@ static void adv_timeout_expire(struct work_struct *work)
566566
hci_dev_unlock(hdev);
567567
}
568568

569+
static bool is_interleave_scanning(struct hci_dev *hdev)
570+
{
571+
return hdev->interleave_scan_state != INTERLEAVE_SCAN_NONE;
572+
}
573+
574+
static int hci_passive_scan_sync(struct hci_dev *hdev);
575+
576+
static void interleave_scan_work(struct work_struct *work)
577+
{
578+
struct hci_dev *hdev = container_of(work, struct hci_dev,
579+
interleave_scan.work);
580+
unsigned long timeout;
581+
582+
if (hdev->interleave_scan_state == INTERLEAVE_SCAN_ALLOWLIST) {
583+
timeout = msecs_to_jiffies(hdev->advmon_allowlist_duration);
584+
} else if (hdev->interleave_scan_state == INTERLEAVE_SCAN_NO_FILTER) {
585+
timeout = msecs_to_jiffies(hdev->advmon_no_filter_duration);
586+
} else {
587+
bt_dev_err(hdev, "unexpected error");
588+
return;
589+
}
590+
591+
hci_passive_scan_sync(hdev);
592+
593+
hci_dev_lock(hdev);
594+
595+
switch (hdev->interleave_scan_state) {
596+
case INTERLEAVE_SCAN_ALLOWLIST:
597+
bt_dev_dbg(hdev, "next state: allowlist");
598+
hdev->interleave_scan_state = INTERLEAVE_SCAN_NO_FILTER;
599+
break;
600+
case INTERLEAVE_SCAN_NO_FILTER:
601+
bt_dev_dbg(hdev, "next state: no filter");
602+
hdev->interleave_scan_state = INTERLEAVE_SCAN_ALLOWLIST;
603+
break;
604+
case INTERLEAVE_SCAN_NONE:
605+
bt_dev_err(hdev, "unexpected error");
606+
}
607+
608+
hci_dev_unlock(hdev);
609+
610+
/* Don't continue interleaving if it was canceled */
611+
if (is_interleave_scanning(hdev))
612+
queue_delayed_work(hdev->req_workqueue,
613+
&hdev->interleave_scan, timeout);
614+
}
615+
569616
void hci_cmd_sync_init(struct hci_dev *hdev)
570617
{
571618
INIT_WORK(&hdev->cmd_sync_work, hci_cmd_sync_work);
@@ -577,6 +624,7 @@ void hci_cmd_sync_init(struct hci_dev *hdev)
577624
INIT_WORK(&hdev->reenable_adv_work, reenable_adv);
578625
INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable);
579626
INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire);
627+
INIT_DELAYED_WORK(&hdev->interleave_scan, interleave_scan_work);
580628
}
581629

582630
static void _hci_cmd_sync_cancel_entry(struct hci_dev *hdev,
@@ -2110,11 +2158,6 @@ static void hci_start_interleave_scan(struct hci_dev *hdev)
21102158
&hdev->interleave_scan, 0);
21112159
}
21122160

2113-
static bool is_interleave_scanning(struct hci_dev *hdev)
2114-
{
2115-
return hdev->interleave_scan_state != INTERLEAVE_SCAN_NONE;
2116-
}
2117-
21182161
static void cancel_interleave_scan(struct hci_dev *hdev)
21192162
{
21202163
bt_dev_dbg(hdev, "cancelling interleave scan");

0 commit comments

Comments
 (0)