aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Tervo <ville.tervo@nokia.com>2011-02-22 14:10:53 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2011-02-27 15:11:29 -0500
commit30e7627219f985cd17a1ac24e0163ebcfb1277bf (patch)
treef4c6688dff4b74d42327ca43b4660b9848c40b01
parentbdce7bafb786701004b2055e15d6ff4b3be678f3 (diff)
Bluetooth: Use ERR_PTR as return error from hci_connect
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>
-rw-r--r--net/bluetooth/hci_conn.c4
-rw-r--r--net/bluetooth/l2cap_core.c11
-rw-r--r--net/bluetooth/mgmt.c4
-rw-r--r--net/bluetooth/sco.c7
4 files changed, 14 insertions, 12 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 4504cb6af6ae..7a6f56b2f49d 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -431,10 +431,10 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
431 if (type == LE_LINK) { 431 if (type == LE_LINK) {
432 le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst); 432 le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
433 if (le) 433 if (le)
434 return NULL; 434 return ERR_PTR(-EBUSY);
435 le = hci_conn_add(hdev, LE_LINK, dst); 435 le = hci_conn_add(hdev, LE_LINK, dst);
436 if (!le) 436 if (!le)
437 return NULL; 437 return ERR_PTR(-ENOMEM);
438 if (le->state == BT_OPEN) 438 if (le->state == BT_OPEN)
439 hci_le_connect(le); 439 hci_le_connect(le);
440 440
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 1db6c9081aa7..c9f9cecca527 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -852,8 +852,6 @@ int l2cap_do_connect(struct sock *sk)
852 852
853 hci_dev_lock_bh(hdev); 853 hci_dev_lock_bh(hdev);
854 854
855 err = -ENOMEM;
856
857 auth_type = l2cap_get_auth_type(sk); 855 auth_type = l2cap_get_auth_type(sk);
858 856
859 if (l2cap_pi(sk)->dcid == L2CAP_CID_LE_DATA) 857 if (l2cap_pi(sk)->dcid == L2CAP_CID_LE_DATA)
@@ -863,17 +861,18 @@ int l2cap_do_connect(struct sock *sk)
863 hcon = hci_connect(hdev, ACL_LINK, dst, 861 hcon = hci_connect(hdev, ACL_LINK, dst,
864 l2cap_pi(sk)->sec_level, auth_type); 862 l2cap_pi(sk)->sec_level, auth_type);
865 863
866 if (!hcon) 864 if (IS_ERR(hcon)) {
865 err = PTR_ERR(hcon);
867 goto done; 866 goto done;
867 }
868 868
869 conn = l2cap_conn_add(hcon, 0); 869 conn = l2cap_conn_add(hcon, 0);
870 if (!conn) { 870 if (!conn) {
871 hci_conn_put(hcon); 871 hci_conn_put(hcon);
872 err = -ENOMEM;
872 goto done; 873 goto done;
873 } 874 }
874 875
875 err = 0;
876
877 /* Update source addr of the socket */ 876 /* Update source addr of the socket */
878 bacpy(src, conn->src); 877 bacpy(src, conn->src);
879 878
@@ -892,6 +891,8 @@ int l2cap_do_connect(struct sock *sk)
892 l2cap_do_start(sk); 891 l2cap_do_start(sk);
893 } 892 }
894 893
894 err = 0;
895
895done: 896done:
896 hci_dev_unlock_bh(hdev); 897 hci_dev_unlock_bh(hdev);
897 hci_dev_put(hdev); 898 hci_dev_put(hdev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 16c7a4d0432c..46c3edc72cd1 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1171,8 +1171,8 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len)
1171 } 1171 }
1172 1172
1173 conn = hci_connect(hdev, ACL_LINK, &cp->bdaddr, sec_level, auth_type); 1173 conn = hci_connect(hdev, ACL_LINK, &cp->bdaddr, sec_level, auth_type);
1174 if (!conn) { 1174 if (IS_ERR(conn)) {
1175 err = -ENOMEM; 1175 err = PTR_ERR(conn);
1176 goto unlock; 1176 goto unlock;
1177 } 1177 }
1178 1178
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index c9348ddda877..42fdffd1d76c 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -190,20 +190,21 @@ static int sco_connect(struct sock *sk)
190 190
191 hci_dev_lock_bh(hdev); 191 hci_dev_lock_bh(hdev);
192 192
193 err = -ENOMEM;
194
195 if (lmp_esco_capable(hdev) && !disable_esco) 193 if (lmp_esco_capable(hdev) && !disable_esco)
196 type = ESCO_LINK; 194 type = ESCO_LINK;
197 else 195 else
198 type = SCO_LINK; 196 type = SCO_LINK;
199 197
200 hcon = hci_connect(hdev, type, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING); 198 hcon = hci_connect(hdev, type, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING);
201 if (!hcon) 199 if (IS_ERR(hcon)) {
200 err = PTR_ERR(hcon);
202 goto done; 201 goto done;
202 }
203 203
204 conn = sco_conn_add(hcon, 0); 204 conn = sco_conn_add(hcon, 0);
205 if (!conn) { 205 if (!conn) {
206 hci_conn_put(hcon); 206 hci_conn_put(hcon);
207 err = -ENOMEM;
207 goto done; 208 goto done;
208 } 209 }
209 210