diff options
author | Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> | 2011-05-31 09:49:26 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-06-08 15:58:18 -0400 |
commit | d7556e20ade582a223ca1792e1f8a7bfd7d5d008 (patch) | |
tree | 7828fb0affae559586e74260c5265e0e15570c5f /net | |
parent | 19f8def031bfa50c579149b200bfeeb919727b27 (diff) |
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_event.c | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 33120b48cbc5..6fc766e107aa 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1487,59 +1487,58 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s | |||
1487 | hci_dev_lock(hdev); | 1487 | hci_dev_lock(hdev); |
1488 | 1488 | ||
1489 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); | 1489 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); |
1490 | if (conn) { | 1490 | if (!conn) |
1491 | if (!ev->status) { | 1491 | goto unlock; |
1492 | if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) && | 1492 | |
1493 | test_bit(HCI_CONN_REAUTH_PEND, | 1493 | if (!ev->status) { |
1494 | &conn->pend)) { | 1494 | if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) && |
1495 | BT_INFO("re-auth of legacy device is not" | 1495 | test_bit(HCI_CONN_REAUTH_PEND, &conn->pend)) { |
1496 | "possible."); | 1496 | BT_INFO("re-auth of legacy device is not possible."); |
1497 | } else { | ||
1498 | conn->link_mode |= HCI_LM_AUTH; | ||
1499 | conn->sec_level = conn->pending_sec_level; | ||
1500 | } | ||
1501 | } else { | 1497 | } else { |
1502 | mgmt_auth_failed(hdev->id, &conn->dst, ev->status); | 1498 | conn->link_mode |= HCI_LM_AUTH; |
1499 | conn->sec_level = conn->pending_sec_level; | ||
1503 | } | 1500 | } |
1501 | } else { | ||
1502 | mgmt_auth_failed(hdev->id, &conn->dst, ev->status); | ||
1503 | } | ||
1504 | 1504 | ||
1505 | clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); | 1505 | clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); |
1506 | clear_bit(HCI_CONN_REAUTH_PEND, &conn->pend); | 1506 | clear_bit(HCI_CONN_REAUTH_PEND, &conn->pend); |
1507 | 1507 | ||
1508 | if (conn->state == BT_CONFIG) { | 1508 | if (conn->state == BT_CONFIG) { |
1509 | if (!ev->status && hdev->ssp_mode > 0 && | 1509 | if (!ev->status && hdev->ssp_mode > 0 && conn->ssp_mode > 0) { |
1510 | conn->ssp_mode > 0) { | 1510 | struct hci_cp_set_conn_encrypt cp; |
1511 | struct hci_cp_set_conn_encrypt cp; | 1511 | cp.handle = ev->handle; |
1512 | cp.handle = ev->handle; | 1512 | cp.encrypt = 0x01; |
1513 | cp.encrypt = 0x01; | 1513 | hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), |
1514 | hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, | 1514 | &cp); |
1515 | sizeof(cp), &cp); | ||
1516 | } else { | ||
1517 | conn->state = BT_CONNECTED; | ||
1518 | hci_proto_connect_cfm(conn, ev->status); | ||
1519 | hci_conn_put(conn); | ||
1520 | } | ||
1521 | } else { | 1515 | } else { |
1522 | hci_auth_cfm(conn, ev->status); | 1516 | conn->state = BT_CONNECTED; |
1523 | 1517 | hci_proto_connect_cfm(conn, ev->status); | |
1524 | hci_conn_hold(conn); | ||
1525 | conn->disc_timeout = HCI_DISCONN_TIMEOUT; | ||
1526 | hci_conn_put(conn); | 1518 | hci_conn_put(conn); |
1527 | } | 1519 | } |
1520 | } else { | ||
1521 | hci_auth_cfm(conn, ev->status); | ||
1528 | 1522 | ||
1529 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { | 1523 | hci_conn_hold(conn); |
1530 | if (!ev->status) { | 1524 | conn->disc_timeout = HCI_DISCONN_TIMEOUT; |
1531 | struct hci_cp_set_conn_encrypt cp; | 1525 | hci_conn_put(conn); |
1532 | cp.handle = ev->handle; | 1526 | } |
1533 | cp.encrypt = 0x01; | 1527 | |
1534 | hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, | 1528 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { |
1535 | sizeof(cp), &cp); | 1529 | if (!ev->status) { |
1536 | } else { | 1530 | struct hci_cp_set_conn_encrypt cp; |
1537 | clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); | 1531 | cp.handle = ev->handle; |
1538 | hci_encrypt_cfm(conn, ev->status, 0x00); | 1532 | cp.encrypt = 0x01; |
1539 | } | 1533 | hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), |
1534 | &cp); | ||
1535 | } else { | ||
1536 | clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); | ||
1537 | hci_encrypt_cfm(conn, ev->status, 0x00); | ||
1540 | } | 1538 | } |
1541 | } | 1539 | } |
1542 | 1540 | ||
1541 | unlock: | ||
1543 | hci_dev_unlock(hdev); | 1542 | hci_dev_unlock(hdev); |
1544 | } | 1543 | } |
1545 | 1544 | ||