mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-16 07:24:39 +08:00
Bluetooth: Refactor hci_auth_complete_evt function
Replace if(conn) with if(!conn) checking to avoid too many nested statements Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
This commit is contained in:
parent
19f8def031
commit
d7556e20ad
@ -1487,13 +1487,13 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
|
|||||||
hci_dev_lock(hdev);
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
|
conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
|
||||||
if (conn) {
|
if (!conn)
|
||||||
|
goto unlock;
|
||||||
|
|
||||||
if (!ev->status) {
|
if (!ev->status) {
|
||||||
if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) &&
|
if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) &&
|
||||||
test_bit(HCI_CONN_REAUTH_PEND,
|
test_bit(HCI_CONN_REAUTH_PEND, &conn->pend)) {
|
||||||
&conn->pend)) {
|
BT_INFO("re-auth of legacy device is not possible.");
|
||||||
BT_INFO("re-auth of legacy device is not"
|
|
||||||
"possible.");
|
|
||||||
} else {
|
} else {
|
||||||
conn->link_mode |= HCI_LM_AUTH;
|
conn->link_mode |= HCI_LM_AUTH;
|
||||||
conn->sec_level = conn->pending_sec_level;
|
conn->sec_level = conn->pending_sec_level;
|
||||||
@ -1506,13 +1506,12 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
|
|||||||
clear_bit(HCI_CONN_REAUTH_PEND, &conn->pend);
|
clear_bit(HCI_CONN_REAUTH_PEND, &conn->pend);
|
||||||
|
|
||||||
if (conn->state == BT_CONFIG) {
|
if (conn->state == BT_CONFIG) {
|
||||||
if (!ev->status && hdev->ssp_mode > 0 &&
|
if (!ev->status && hdev->ssp_mode > 0 && conn->ssp_mode > 0) {
|
||||||
conn->ssp_mode > 0) {
|
|
||||||
struct hci_cp_set_conn_encrypt cp;
|
struct hci_cp_set_conn_encrypt cp;
|
||||||
cp.handle = ev->handle;
|
cp.handle = ev->handle;
|
||||||
cp.encrypt = 0x01;
|
cp.encrypt = 0x01;
|
||||||
hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT,
|
hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp),
|
||||||
sizeof(cp), &cp);
|
&cp);
|
||||||
} else {
|
} else {
|
||||||
conn->state = BT_CONNECTED;
|
conn->state = BT_CONNECTED;
|
||||||
hci_proto_connect_cfm(conn, ev->status);
|
hci_proto_connect_cfm(conn, ev->status);
|
||||||
@ -1531,15 +1530,15 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
|
|||||||
struct hci_cp_set_conn_encrypt cp;
|
struct hci_cp_set_conn_encrypt cp;
|
||||||
cp.handle = ev->handle;
|
cp.handle = ev->handle;
|
||||||
cp.encrypt = 0x01;
|
cp.encrypt = 0x01;
|
||||||
hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT,
|
hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp),
|
||||||
sizeof(cp), &cp);
|
&cp);
|
||||||
} else {
|
} else {
|
||||||
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
|
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
|
||||||
hci_encrypt_cfm(conn, ev->status, 0x00);
|
hci_encrypt_cfm(conn, ev->status, 0x00);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
unlock:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock(hdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user