aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2011-11-09 15:14:26 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2011-11-16 12:40:30 -0500
commite6d465cb482935c26cb4065a6ab9ce987c067da3 (patch)
treeea027e48cb8347f860cec32ae3b66287bd943502
parent7a13510902c81ad865f6d02aed2f4e053a46050e (diff)
Bluetooth: mgmt_stop_discovery_failed()
This patches creates mgmt_stop_discovery_failed() which removes pending MGMT_OP_STOP_DISCOVERY commands and sends proper command status events. This patch also fixes the MGMT_OP_STOP_DISCOVERY command leak in case cancel inquiry fails. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r--include/net/bluetooth/hci_core.h1
-rw-r--r--net/bluetooth/hci_event.c6
-rw-r--r--net/bluetooth/mgmt.c15
3 files changed, 21 insertions, 1 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 827bedab6a70..1795257f4063 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -941,6 +941,7 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
941 u8 addr_type, u8 *dev_class, s8 rssi, u8 *eir); 941 u8 addr_type, u8 *dev_class, s8 rssi, u8 *eir);
942int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); 942int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name);
943int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); 943int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status);
944int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status);
944int mgmt_discovering(struct hci_dev *hdev, u8 discovering); 945int mgmt_discovering(struct hci_dev *hdev, u8 discovering);
945int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr); 946int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr);
946int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr); 947int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 53b2071adfad..dfe6fbc8fc9a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -55,8 +55,12 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
55 55
56 BT_DBG("%s status 0x%x", hdev->name, status); 56 BT_DBG("%s status 0x%x", hdev->name, status);
57 57
58 if (status) 58 if (status) {
59 hci_dev_lock(hdev);
60 mgmt_stop_discovery_failed(hdev, status);
61 hci_dev_unlock(hdev);
59 return; 62 return;
63 }
60 64
61 clear_bit(HCI_INQUIRY, &hdev->flags); 65 clear_bit(HCI_INQUIRY, &hdev->flags);
62 66
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 9fdea980be98..bd77f54d91f7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2443,6 +2443,21 @@ int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status)
2443 return err; 2443 return err;
2444} 2444}
2445 2445
2446int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status)
2447{
2448 struct pending_cmd *cmd;
2449 int err;
2450
2451 cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, hdev);
2452 if (!cmd)
2453 return -ENOENT;
2454
2455 err = cmd_status(cmd->sk, hdev->id, cmd->opcode, status);
2456 mgmt_pending_remove(cmd);
2457
2458 return err;
2459}
2460
2446int mgmt_discovering(struct hci_dev *hdev, u8 discovering) 2461int mgmt_discovering(struct hci_dev *hdev, u8 discovering)
2447{ 2462{
2448 struct pending_cmd *cmd; 2463 struct pending_cmd *cmd;