aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_event.c
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2012-07-27 14:10:16 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-08-06 14:08:41 -0400
commitcd17decbd9af41c9548bb108ccf156519f8253ec (patch)
tree784ec92b28fa9de6fae9f55451deed2dd9d6ec9f /net/bluetooth/hci_event.c
parentb47a09b33a4612ace2958996ce6e0134be23d043 (diff)
Bluetooth: Refactor in hci_le_conn_complete_evt
This patch moves the hci_conn check to begining of hci_le_conn_ complete_evt in order to improve code's readability and better error handling. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r--net/bluetooth/hci_event.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 92522b470f6b..32e21ad36a68 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3334,19 +3334,6 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
3334 hci_dev_lock(hdev); 3334 hci_dev_lock(hdev);
3335 3335
3336 conn = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT); 3336 conn = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT);
3337
3338 if (ev->status) {
3339 if (!conn)
3340 goto unlock;
3341
3342 mgmt_connect_failed(hdev, &conn->dst, conn->type,
3343 conn->dst_type, ev->status);
3344 hci_proto_connect_cfm(conn, ev->status);
3345 conn->state = BT_CLOSED;
3346 hci_conn_del(conn);
3347 goto unlock;
3348 }
3349
3350 if (!conn) { 3337 if (!conn) {
3351 conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr); 3338 conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr);
3352 if (!conn) { 3339 if (!conn) {
@@ -3362,6 +3349,15 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
3362 } 3349 }
3363 } 3350 }
3364 3351
3352 if (ev->status) {
3353 mgmt_connect_failed(hdev, &conn->dst, conn->type,
3354 conn->dst_type, ev->status);
3355 hci_proto_connect_cfm(conn, ev->status);
3356 conn->state = BT_CLOSED;
3357 hci_conn_del(conn);
3358 goto unlock;
3359 }
3360
3365 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) 3361 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
3366 mgmt_device_connected(hdev, &ev->bdaddr, conn->type, 3362 mgmt_device_connected(hdev, &ev->bdaddr, conn->type,
3367 conn->dst_type, 0, NULL, 0, NULL); 3363 conn->dst_type, 0, NULL, 0, NULL);