Bluetooth: Fix command complete/status for discovery commands
authorJohan Hedberg <johan.hedberg@intel.com>
Tue, 1 Nov 2011 15:06:44 +0000 (17:06 +0200)
committerGustavo F. Padovan <padovan@profusion.mobi>
Mon, 7 Nov 2011 19:24:48 +0000 (17:24 -0200)
This patch adds the necessary code to send proper command status or
command complete events to the start/stop discovery management commands.
Before this patch these events were completely missing.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_event.c
net/bluetooth/mgmt.c

index 9285a650949cee628c8ef09b95cc44b64cf50076..5a9db9a4b439494f005bbc220015aee20de44385 100644 (file)
@@ -887,6 +887,7 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,
 int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi,
                                                                u8 *eir);
 int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name);
+int mgmt_inquiry_failed(u16 index, u8 status);
 int mgmt_discovering(u16 index, u8 discovering);
 int mgmt_device_blocked(u16 index, bdaddr_t *bdaddr);
 int mgmt_device_unblocked(u16 index, bdaddr_t *bdaddr);
index 41967fec12b7e46ff6752b4795d09ae8319d4fb8..d8fa65709aedda32fe91b44fda0c5fcc4d153577 100644 (file)
@@ -979,6 +979,8 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
        if (status) {
                hci_req_complete(hdev, HCI_OP_INQUIRY, status);
                hci_conn_check_pending(hdev);
+               if (test_bit(HCI_MGMT, &hdev->flags))
+                       mgmt_inquiry_failed(hdev->id, status);
                return;
        }
 
index 7809aa979358444a77ead8b9102cc7ca1c783963..38220a2dc31e9f3e45daf98f6dae303d9d026369 100644 (file)
@@ -2339,8 +2339,35 @@ int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name)
        return mgmt_event(MGMT_EV_REMOTE_NAME, index, &ev, sizeof(ev), NULL);
 }
 
+int mgmt_inquiry_failed(u16 index, u8 status)
+{
+       struct pending_cmd *cmd;
+       int err;
+
+       cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, index);
+       if (!cmd)
+               return -ENOENT;
+
+       err = cmd_status(cmd->sk, index, cmd->opcode, status);
+       mgmt_pending_remove(cmd);
+
+       return err;
+}
+
 int mgmt_discovering(u16 index, u8 discovering)
 {
+       struct pending_cmd *cmd;
+
+       if (discovering)
+               cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, index);
+       else
+               cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, index);
+
+       if (cmd != NULL) {
+               cmd_complete(cmd->sk, index, cmd->opcode, NULL, 0);
+               mgmt_pending_remove(cmd);
+       }
+
        return mgmt_event(MGMT_EV_DISCOVERING, index, &discovering,
                                                sizeof(discovering), NULL);
 }