All of the places that need to call mgmt_pending_remove already have a
pointer to the pending command, so searching for the command in the list
doesn't make sense. The added benefit is that many places that
previously had to call list_del + mgmt_pending_free can just call
mgmt_pending_remove now.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-static void mgmt_pending_remove(u16 opcode, int index)
+static void mgmt_pending_remove(struct pending_cmd *cmd)
- struct pending_cmd *cmd;
-
- cmd = mgmt_pending_find(opcode, index);
- if (cmd == NULL)
- return;
-
list_del(&cmd->list);
mgmt_pending_free(cmd);
}
list_del(&cmd->list);
mgmt_pending_free(cmd);
}
err = hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
if (err < 0)
err = hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
if (err < 0)
- mgmt_pending_remove(MGMT_OP_SET_DISCOVERABLE, dev_id);
+ mgmt_pending_remove(cmd);
failed:
hci_dev_unlock_bh(hdev);
failed:
hci_dev_unlock_bh(hdev);
err = hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
if (err < 0)
err = hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
if (err < 0)
- mgmt_pending_remove(MGMT_OP_SET_CONNECTABLE, dev_id);
+ mgmt_pending_remove(cmd);
failed:
hci_dev_unlock_bh(hdev);
failed:
hci_dev_unlock_bh(hdev);
err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc);
if (err < 0)
err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc);
if (err < 0)
- mgmt_pending_remove(MGMT_OP_DISCONNECT, dev_id);
+ mgmt_pending_remove(cmd);
failed:
hci_dev_unlock_bh(hdev);
failed:
hci_dev_unlock_bh(hdev);
err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_REPLY, sizeof(reply), &reply);
if (err < 0)
err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_REPLY, sizeof(reply), &reply);
if (err < 0)
- mgmt_pending_remove(MGMT_OP_PIN_CODE_REPLY, dev_id);
+ mgmt_pending_remove(cmd);
failed:
hci_dev_unlock_bh(hdev);
failed:
hci_dev_unlock_bh(hdev);
err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, sizeof(bdaddr_t),
&cp->bdaddr);
if (err < 0)
err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, sizeof(bdaddr_t),
&cp->bdaddr);
if (err < 0)
- mgmt_pending_remove(MGMT_OP_PIN_CODE_NEG_REPLY, dev_id);
+ mgmt_pending_remove(cmd);
failed:
hci_dev_unlock_bh(hdev);
failed:
hci_dev_unlock_bh(hdev);
- list_del(&cmd->list);
- mgmt_pending_free(cmd);
+ mgmt_pending_remove(cmd);
}
static void pairing_complete_cb(struct hci_conn *conn, u8 status)
}
static void pairing_complete_cb(struct hci_conn *conn, u8 status)
}
err = hci_send_cmd(hdev, hci_op, sizeof(cp->bdaddr), &cp->bdaddr);
}
err = hci_send_cmd(hdev, hci_op, sizeof(cp->bdaddr), &cp->bdaddr);
- if (err < 0) {
- list_del(&cmd->list);
- mgmt_pending_free(cmd);
- }
+ if (err < 0)
+ mgmt_pending_remove(cmd);
failed:
hci_dev_unlock_bh(hdev);
failed:
hci_dev_unlock_bh(hdev);
*sk = cmd->sk;
sock_hold(*sk);
*sk = cmd->sk;
sock_hold(*sk);
- list_del(&cmd->list);
- mgmt_pending_free(cmd);
+ mgmt_pending_remove(cmd);
}
int mgmt_disconnected(u16 index, bdaddr_t *bdaddr)
}
int mgmt_disconnected(u16 index, bdaddr_t *bdaddr)
err = cmd_status(cmd->sk, MGMT_OP_DISCONNECT, EIO);
err = cmd_status(cmd->sk, MGMT_OP_DISCONNECT, EIO);
- list_del(&cmd->list);
- mgmt_pending_free(cmd);
+ mgmt_pending_remove(cmd);
err = cmd_complete(cmd->sk, MGMT_OP_PIN_CODE_REPLY, &rp, sizeof(rp));
err = cmd_complete(cmd->sk, MGMT_OP_PIN_CODE_REPLY, &rp, sizeof(rp));
- list_del(&cmd->list);
- mgmt_pending_free(cmd);
+ mgmt_pending_remove(cmd);
err = cmd_complete(cmd->sk, MGMT_OP_PIN_CODE_NEG_REPLY,
&rp, sizeof(rp));
err = cmd_complete(cmd->sk, MGMT_OP_PIN_CODE_NEG_REPLY,
&rp, sizeof(rp));
- list_del(&cmd->list);
- mgmt_pending_free(cmd);
+ mgmt_pending_remove(cmd);
rp.status = status;
err = cmd_complete(cmd->sk, opcode, &rp, sizeof(rp));
rp.status = status;
err = cmd_complete(cmd->sk, opcode, &rp, sizeof(rp));
- list_del(&cmd->list);
- mgmt_pending_free(cmd);
+ mgmt_pending_remove(cmd);