diff options
author | Andre Guedes <andre.guedes@openbossa.org> | 2011-11-04 13:16:52 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-11-08 09:54:08 -0500 |
commit | 023d50498d04c77b73eed11d849e436ef5639ed2 (patch) | |
tree | 8e8e6846b835041937c9f242403c868003478981 /net/bluetooth | |
parent | 2519a1fc82490eb13d69610f81fe84930f3b0e3f (diff) |
Bluetooth: Create hci_cancel_inquiry()
This patch adds a function to hci_core to cancel an ongoing inquiry.
According to the Bluetooth spec, the inquiry cancel command should
only be issued after the inquiry command has been issued, a command
status event has been received for the inquiry command, and before
the inquiry complete event occurs.
As HCI_INQUIRY flag is only set just after an inquiry command status
event occurs and it is cleared just after an inquiry complete event
occurs, the inquiry cancel command should be issued only if HCI_INQUIRY
flag is set.
Additionally, cancel inquiry related code from stop_discovery() were
replaced by a hci_cancel_inquiry() call.
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_core.c | 10 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e6e991331ef8..6a4bd2d8da99 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -2578,3 +2578,13 @@ int hci_do_inquiry(struct hci_dev *hdev, u8 length) | |||
2578 | 2578 | ||
2579 | return hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp); | 2579 | return hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp); |
2580 | } | 2580 | } |
2581 | |||
2582 | int hci_cancel_inquiry(struct hci_dev *hdev) | ||
2583 | { | ||
2584 | BT_DBG("%s", hdev->name); | ||
2585 | |||
2586 | if (!test_bit(HCI_INQUIRY, &hdev->flags)) | ||
2587 | return -EPERM; | ||
2588 | |||
2589 | return hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL); | ||
2590 | } | ||
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 17c7fbbc1210..0f9ef9432462 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1649,7 +1649,7 @@ static int stop_discovery(struct sock *sk, u16 index) | |||
1649 | goto failed; | 1649 | goto failed; |
1650 | } | 1650 | } |
1651 | 1651 | ||
1652 | err = hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL); | 1652 | err = hci_cancel_inquiry(hdev); |
1653 | if (err < 0) | 1653 | if (err < 0) |
1654 | mgmt_pending_remove(cmd); | 1654 | mgmt_pending_remove(cmd); |
1655 | 1655 | ||