mirror of
https://github.com/torvalds/linux.git
synced 2024-11-06 03:51:48 +00:00
Bluetooth: Convert Get Clock Info to use cmd_complete callback
This patch converts the Get Clock Information mgmt command to take advantage of the new cmd_complete callback for pending commands. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
2922a94fcc
commit
69487371d1
@ -5287,10 +5287,40 @@ unlock:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clock_info_cmd_complete(struct pending_cmd *cmd, u8 status)
|
||||||
|
{
|
||||||
|
struct hci_conn *conn = cmd->user_data;
|
||||||
|
struct mgmt_rp_get_clock_info rp;
|
||||||
|
struct hci_dev *hdev;
|
||||||
|
|
||||||
|
memset(&rp, 0, sizeof(rp));
|
||||||
|
memcpy(&rp.addr, &cmd->param, sizeof(rp.addr));
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
goto complete;
|
||||||
|
|
||||||
|
hdev = hci_dev_get(cmd->index);
|
||||||
|
if (hdev) {
|
||||||
|
rp.local_clock = cpu_to_le32(hdev->clock);
|
||||||
|
hci_dev_put(hdev);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (conn) {
|
||||||
|
rp.piconet_clock = cpu_to_le32(conn->clock);
|
||||||
|
rp.accuracy = cpu_to_le16(conn->clock_accuracy);
|
||||||
|
}
|
||||||
|
|
||||||
|
complete:
|
||||||
|
cmd_complete(cmd->sk, cmd->index, cmd->opcode, status, &rp, sizeof(rp));
|
||||||
|
|
||||||
|
if (conn) {
|
||||||
|
hci_conn_drop(conn);
|
||||||
|
hci_conn_put(conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void get_clock_info_complete(struct hci_dev *hdev, u8 status)
|
static void get_clock_info_complete(struct hci_dev *hdev, u8 status)
|
||||||
{
|
{
|
||||||
struct mgmt_cp_get_clock_info *cp;
|
|
||||||
struct mgmt_rp_get_clock_info rp;
|
|
||||||
struct hci_cp_read_clock *hci_cp;
|
struct hci_cp_read_clock *hci_cp;
|
||||||
struct pending_cmd *cmd;
|
struct pending_cmd *cmd;
|
||||||
struct hci_conn *conn;
|
struct hci_conn *conn;
|
||||||
@ -5314,29 +5344,8 @@ static void get_clock_info_complete(struct hci_dev *hdev, u8 status)
|
|||||||
if (!cmd)
|
if (!cmd)
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
cp = cmd->param;
|
cmd->cmd_complete(cmd, mgmt_status(status));
|
||||||
|
|
||||||
memset(&rp, 0, sizeof(rp));
|
|
||||||
memcpy(&rp.addr, &cp->addr, sizeof(rp.addr));
|
|
||||||
|
|
||||||
if (status)
|
|
||||||
goto send_rsp;
|
|
||||||
|
|
||||||
rp.local_clock = cpu_to_le32(hdev->clock);
|
|
||||||
|
|
||||||
if (conn) {
|
|
||||||
rp.piconet_clock = cpu_to_le32(conn->clock);
|
|
||||||
rp.accuracy = cpu_to_le16(conn->clock_accuracy);
|
|
||||||
}
|
|
||||||
|
|
||||||
send_rsp:
|
|
||||||
cmd_complete(cmd->sk, cmd->index, cmd->opcode, mgmt_status(status),
|
|
||||||
&rp, sizeof(rp));
|
|
||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
if (conn) {
|
|
||||||
hci_conn_drop(conn);
|
|
||||||
hci_conn_put(conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock(hdev);
|
||||||
@ -5392,6 +5401,8 @@ static int get_clock_info(struct sock *sk, struct hci_dev *hdev, void *data,
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd->cmd_complete = clock_info_cmd_complete;
|
||||||
|
|
||||||
hci_req_init(&req, hdev);
|
hci_req_init(&req, hdev);
|
||||||
|
|
||||||
memset(&hci_cp, 0, sizeof(hci_cp));
|
memset(&hci_cp, 0, sizeof(hci_cp));
|
||||||
|
Loading…
Reference in New Issue
Block a user