diff options
| author | Johan Hedberg <johan.hedberg@intel.com> | 2014-12-05 06:36:02 -0500 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2014-12-05 06:46:09 -0500 |
| commit | f5818c2241247c0a5f967e41e952682b10db6fd6 (patch) | |
| tree | 740cdcb1d7182af68409501fa924854208f14bf9 /net/bluetooth | |
| parent | 323b0b885b5586a39a288d8f10c3a6c7ba901282 (diff) | |
Bluetooth: Convert Disconnect mgmt command to use cmd_complete callback
This patch converts the Disconnect mgmt command to take advantage of the
new cmd_complete callback that's part of the pending_cmd struct. There
are many commands whose response parameters map 1:1 to the command
parameters and Disconnect is one of them. This patch adds a
generic_cmd_complete() function for such commands that can be reused in
subsequent patches.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
| -rw-r--r-- | net/bluetooth/mgmt.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 56c7838c0a41..81b2886f64b8 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
| @@ -1486,6 +1486,12 @@ static void cmd_complete_rsp(struct pending_cmd *cmd, void *data) | |||
| 1486 | cmd_status_rsp(cmd, data); | 1486 | cmd_status_rsp(cmd, data); |
| 1487 | } | 1487 | } |
| 1488 | 1488 | ||
| 1489 | static void generic_cmd_complete(struct pending_cmd *cmd, u8 status) | ||
| 1490 | { | ||
| 1491 | cmd_complete(cmd->sk, cmd->index, cmd->opcode, status, cmd->param, | ||
| 1492 | cmd->param_len); | ||
| 1493 | } | ||
| 1494 | |||
| 1489 | static u8 mgmt_bredr_support(struct hci_dev *hdev) | 1495 | static u8 mgmt_bredr_support(struct hci_dev *hdev) |
| 1490 | { | 1496 | { |
| 1491 | if (!lmp_bredr_capable(hdev)) | 1497 | if (!lmp_bredr_capable(hdev)) |
| @@ -2872,6 +2878,8 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, | |||
| 2872 | goto failed; | 2878 | goto failed; |
| 2873 | } | 2879 | } |
| 2874 | 2880 | ||
| 2881 | cmd->cmd_complete = generic_cmd_complete; | ||
| 2882 | |||
| 2875 | err = hci_disconnect(conn, HCI_ERROR_REMOTE_USER_TERM); | 2883 | err = hci_disconnect(conn, HCI_ERROR_REMOTE_USER_TERM); |
| 2876 | if (err < 0) | 2884 | if (err < 0) |
| 2877 | mgmt_pending_remove(cmd); | 2885 | mgmt_pending_remove(cmd); |
| @@ -6396,15 +6404,9 @@ void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn, | |||
| 6396 | 6404 | ||
| 6397 | static void disconnect_rsp(struct pending_cmd *cmd, void *data) | 6405 | static void disconnect_rsp(struct pending_cmd *cmd, void *data) |
| 6398 | { | 6406 | { |
| 6399 | struct mgmt_cp_disconnect *cp = cmd->param; | ||
| 6400 | struct sock **sk = data; | 6407 | struct sock **sk = data; |
| 6401 | struct mgmt_rp_disconnect rp; | ||
| 6402 | 6408 | ||
| 6403 | bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); | 6409 | cmd->cmd_complete(cmd, 0); |
| 6404 | rp.addr.type = cp->addr.type; | ||
| 6405 | |||
| 6406 | cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, 0, &rp, | ||
| 6407 | sizeof(rp)); | ||
| 6408 | 6410 | ||
| 6409 | *sk = cmd->sk; | 6411 | *sk = cmd->sk; |
| 6410 | sock_hold(*sk); | 6412 | sock_hold(*sk); |
| @@ -6486,7 +6488,6 @@ void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, | |||
| 6486 | { | 6488 | { |
| 6487 | u8 bdaddr_type = link_to_bdaddr(link_type, addr_type); | 6489 | u8 bdaddr_type = link_to_bdaddr(link_type, addr_type); |
| 6488 | struct mgmt_cp_disconnect *cp; | 6490 | struct mgmt_cp_disconnect *cp; |
| 6489 | struct mgmt_rp_disconnect rp; | ||
| 6490 | struct pending_cmd *cmd; | 6491 | struct pending_cmd *cmd; |
| 6491 | 6492 | ||
| 6492 | mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp, | 6493 | mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp, |
| @@ -6504,12 +6505,7 @@ void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, | |||
| 6504 | if (cp->addr.type != bdaddr_type) | 6505 | if (cp->addr.type != bdaddr_type) |
| 6505 | return; | 6506 | return; |
| 6506 | 6507 | ||
| 6507 | bacpy(&rp.addr.bdaddr, bdaddr); | 6508 | cmd->cmd_complete(cmd, mgmt_status(status)); |
| 6508 | rp.addr.type = bdaddr_type; | ||
| 6509 | |||
| 6510 | cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, | ||
| 6511 | mgmt_status(status), &rp, sizeof(rp)); | ||
| 6512 | |||
| 6513 | mgmt_pending_remove(cmd); | 6509 | mgmt_pending_remove(cmd); |
| 6514 | } | 6510 | } |
| 6515 | 6511 | ||
