aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2012-07-27 14:10:13 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-08-06 14:07:05 -0400
commitf00a06ac14becc3d78fecdf2513cc23ee267a96b (patch)
tree1e8d9fd60e17db6463499e087701d344912dfae3 /net
parent847012c5e04544aef485dfec29c1c07dc90615a4 (diff)
Bluetooth: Refactor hci_cs_le_create_conn
This patch does some code refactoring in hci_cs_le_create_conn function. The hci_conn object is only needed in case of failure, therefore hdev locking and hci_conn lookup were moved to if-statement scope. Also, the conn->state check was removed since we should always close the connection if it fails. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_event.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 27064beda10d..c0aa9f436998 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1623,24 +1623,26 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
1623 if (!cp) 1623 if (!cp)
1624 return; 1624 return;
1625 1625
1626 hci_dev_lock(hdev); 1626 if (status) {
1627 hci_dev_lock(hdev);
1627 1628
1628 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->peer_addr); 1629 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->peer_addr);
1630 if (!conn) {
1631 hci_dev_unlock(hdev);
1632 return;
1633 }
1629 1634
1630 BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&cp->peer_addr), 1635 BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&cp->peer_addr),
1631 conn); 1636 conn);
1632 1637
1633 if (status) { 1638 conn->state = BT_CLOSED;
1634 if (conn && conn->state == BT_CONNECT) { 1639 mgmt_connect_failed(hdev, &cp->peer_addr, conn->type,
1635 conn->state = BT_CLOSED; 1640 conn->dst_type, status);
1636 mgmt_connect_failed(hdev, &cp->peer_addr, conn->type, 1641 hci_proto_connect_cfm(conn, status);
1637 conn->dst_type, status); 1642 hci_conn_del(conn);
1638 hci_proto_connect_cfm(conn, status);
1639 hci_conn_del(conn);
1640 }
1641 }
1642 1643
1643 hci_dev_unlock(hdev); 1644 hci_dev_unlock(hdev);
1645 }
1644} 1646}
1645 1647
1646static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status) 1648static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status)