Use ERR_PTR mechanism to return error from hci_connect.
Signed-off-by: Ville Tervo <ville.tervo@nokia.com>
Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
if (type == LE_LINK) {
le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
if (le)
- return NULL;
+ return ERR_PTR(-EBUSY);
le = hci_conn_add(hdev, LE_LINK, dst);
if (!le)
- return NULL;
+ return ERR_PTR(-ENOMEM);
if (le->state == BT_OPEN)
hci_le_connect(le);
hci_dev_lock_bh(hdev);
- err = -ENOMEM;
-
auth_type = l2cap_get_auth_type(sk);
if (l2cap_pi(sk)->dcid == L2CAP_CID_LE_DATA)
hcon = hci_connect(hdev, ACL_LINK, dst,
l2cap_pi(sk)->sec_level, auth_type);
- if (!hcon)
+ if (IS_ERR(hcon)) {
+ err = PTR_ERR(hcon);
goto done;
+ }
conn = l2cap_conn_add(hcon, 0);
if (!conn) {
hci_conn_put(hcon);
+ err = -ENOMEM;
goto done;
}
- err = 0;
-
/* Update source addr of the socket */
bacpy(src, conn->src);
l2cap_do_start(sk);
}
+ err = 0;
+
done:
hci_dev_unlock_bh(hdev);
hci_dev_put(hdev);
}
conn = hci_connect(hdev, ACL_LINK, &cp->bdaddr, sec_level, auth_type);
- if (!conn) {
- err = -ENOMEM;
+ if (IS_ERR(conn)) {
+ err = PTR_ERR(conn);
goto unlock;
}
hci_dev_lock_bh(hdev);
- err = -ENOMEM;
-
if (lmp_esco_capable(hdev) && !disable_esco)
type = ESCO_LINK;
else
type = SCO_LINK;
hcon = hci_connect(hdev, type, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING);
- if (!hcon)
+ if (IS_ERR(hcon)) {
+ err = PTR_ERR(hcon);
goto done;
+ }
conn = sco_conn_add(hcon, 0);
if (!conn) {
hci_conn_put(hcon);
+ err = -ENOMEM;
goto done;
}