Bluetooth: Update the scan state with Inquiry commands in non-LE case
Update the hdev scan state with Inquiry start/cancel commands in
non-LE case accordingly. And also there was no check to see the
SCAN_BR mode before sending inquiry cancel.Added a check to see
if the scan state is SCAN_BR,then send inquiry cancel
Change-Id: I222f500fc20b991f4c3ec7eb1fc70bf20649f142
Signed-off-by: Bhasker Neti <bneti@codeaurora.org>
CRs-fixed: 359771
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b773553..dce8491 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2137,9 +2137,10 @@
err = hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp);
- if (err < 0)
+ if (err < 0) {
mgmt_pending_remove(cmd);
- else if (lmp_le_capable(hdev)) {
+ hdev->disco_state = SCAN_IDLE;
+ } else if (lmp_le_capable(hdev)) {
cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, index);
if (!cmd)
mgmt_pending_add(sk, MGMT_OP_STOP_DISCOVERY, index,
@@ -2151,7 +2152,8 @@
del_timer(&hdev->disco_timer);
mod_timer(&hdev->disco_timer,
jiffies + msecs_to_jiffies(20000));
- }
+ } else
+ hdev->disco_state = SCAN_BR;
failed:
hci_dev_unlock_bh(hdev);
@@ -2195,9 +2197,7 @@
err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY,
NULL, 0);
}
- }
-
- if (err < 0)
+ } else if (state == SCAN_BR)
err = hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL);
cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, index);