Commit ec182f03 authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

Bluetooth: Remove unnecessary indentation in unpair_device()

Instead of doing all of the LE-specific handling in an else-branch in
unpair_device() create a 'done' label for the BR/EDR branch to jump to
and then remove the else-branch completely.
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent f5ad4ffc
...@@ -3055,6 +3055,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -3055,6 +3055,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
struct hci_cp_disconnect dc; struct hci_cp_disconnect dc;
struct mgmt_pending_cmd *cmd; struct mgmt_pending_cmd *cmd;
struct hci_conn *conn; struct hci_conn *conn;
u8 addr_type;
int err; int err;
memset(&rp, 0, sizeof(rp)); memset(&rp, 0, sizeof(rp));
...@@ -3095,33 +3096,23 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -3095,33 +3096,23 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
conn = NULL; conn = NULL;
err = hci_remove_link_key(hdev, &cp->addr.bdaddr); err = hci_remove_link_key(hdev, &cp->addr.bdaddr);
} else { if (err < 0) {
u8 addr_type = le_addr_type(cp->addr.type); err = mgmt_cmd_complete(sk, hdev->id,
MGMT_OP_UNPAIR_DEVICE,
conn = hci_conn_hash_lookup_le(hdev, &cp->addr.bdaddr, MGMT_STATUS_NOT_PAIRED, &rp,
addr_type); sizeof(rp));
if (conn) { goto unlock;
/* Defer clearing up the connection parameters
* until closing to give a chance of keeping
* them if a repairing happens.
*/
set_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags);
/* If disconnection is not requested, then
* clear the connection variable so that the
* link is not terminated.
*/
if (!cp->disconnect)
conn = NULL;
} else {
hci_conn_params_del(hdev, &cp->addr.bdaddr, addr_type);
} }
hci_remove_irk(hdev, &cp->addr.bdaddr, addr_type); goto done;
err = hci_remove_ltk(hdev, &cp->addr.bdaddr, addr_type);
} }
/* LE address type */
addr_type = le_addr_type(cp->addr.type);
hci_remove_irk(hdev, &cp->addr.bdaddr, addr_type);
err = hci_remove_ltk(hdev, &cp->addr.bdaddr, addr_type);
if (err < 0) { if (err < 0) {
err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE,
MGMT_STATUS_NOT_PAIRED, &rp, MGMT_STATUS_NOT_PAIRED, &rp,
...@@ -3129,6 +3120,24 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -3129,6 +3120,24 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
goto unlock; goto unlock;
} }
conn = hci_conn_hash_lookup_le(hdev, &cp->addr.bdaddr, addr_type);
if (!conn) {
hci_conn_params_del(hdev, &cp->addr.bdaddr, addr_type);
goto done;
}
/* Defer clearing up the connection parameters until closing to
* give a chance of keeping them if a repairing happens.
*/
set_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags);
/* If disconnection is not requested, then clear the connection
* variable so that the link is not terminated.
*/
if (!cp->disconnect)
conn = NULL;
done:
/* If the connection variable is set, then termination of the /* If the connection variable is set, then termination of the
* link is requested. * link is requested.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment