diff options
Diffstat (limited to 'net/bluetooth/sco.c')
-rw-r--r-- | net/bluetooth/sco.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 960c6d1637da..94954c74f6ae 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -50,8 +50,6 @@ | |||
50 | #include <net/bluetooth/hci_core.h> | 50 | #include <net/bluetooth/hci_core.h> |
51 | #include <net/bluetooth/sco.h> | 51 | #include <net/bluetooth/sco.h> |
52 | 52 | ||
53 | #define VERSION "0.6" | ||
54 | |||
55 | static int disable_esco; | 53 | static int disable_esco; |
56 | 54 | ||
57 | static const struct proto_ops sco_sock_ops; | 55 | static const struct proto_ops sco_sock_ops; |
@@ -192,20 +190,21 @@ static int sco_connect(struct sock *sk) | |||
192 | 190 | ||
193 | hci_dev_lock_bh(hdev); | 191 | hci_dev_lock_bh(hdev); |
194 | 192 | ||
195 | err = -ENOMEM; | ||
196 | |||
197 | if (lmp_esco_capable(hdev) && !disable_esco) | 193 | if (lmp_esco_capable(hdev) && !disable_esco) |
198 | type = ESCO_LINK; | 194 | type = ESCO_LINK; |
199 | else | 195 | else |
200 | type = SCO_LINK; | 196 | type = SCO_LINK; |
201 | 197 | ||
202 | 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); |
203 | if (!hcon) | 199 | if (IS_ERR(hcon)) { |
200 | err = PTR_ERR(hcon); | ||
204 | goto done; | 201 | goto done; |
202 | } | ||
205 | 203 | ||
206 | conn = sco_conn_add(hcon, 0); | 204 | conn = sco_conn_add(hcon, 0); |
207 | if (!conn) { | 205 | if (!conn) { |
208 | hci_conn_put(hcon); | 206 | hci_conn_put(hcon); |
207 | err = -ENOMEM; | ||
209 | goto done; | 208 | goto done; |
210 | } | 209 | } |
211 | 210 | ||
@@ -370,6 +369,15 @@ static void __sco_sock_close(struct sock *sk) | |||
370 | 369 | ||
371 | case BT_CONNECTED: | 370 | case BT_CONNECTED: |
372 | case BT_CONFIG: | 371 | case BT_CONFIG: |
372 | if (sco_pi(sk)->conn) { | ||
373 | sk->sk_state = BT_DISCONN; | ||
374 | sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT); | ||
375 | hci_conn_put(sco_pi(sk)->conn->hcon); | ||
376 | sco_pi(sk)->conn = NULL; | ||
377 | } else | ||
378 | sco_chan_del(sk, ECONNRESET); | ||
379 | break; | ||
380 | |||
373 | case BT_CONNECT: | 381 | case BT_CONNECT: |
374 | case BT_DISCONN: | 382 | case BT_DISCONN: |
375 | sco_chan_del(sk, ECONNRESET); | 383 | sco_chan_del(sk, ECONNRESET); |
@@ -703,6 +711,7 @@ static int sco_sock_getsockopt_old(struct socket *sock, int optname, char __user | |||
703 | break; | 711 | break; |
704 | } | 712 | } |
705 | 713 | ||
714 | memset(&cinfo, 0, sizeof(cinfo)); | ||
706 | cinfo.hci_handle = sco_pi(sk)->conn->hcon->handle; | 715 | cinfo.hci_handle = sco_pi(sk)->conn->hcon->handle; |
707 | memcpy(cinfo.dev_class, sco_pi(sk)->conn->hcon->dev_class, 3); | 716 | memcpy(cinfo.dev_class, sco_pi(sk)->conn->hcon->dev_class, 3); |
708 | 717 | ||
@@ -1023,7 +1032,7 @@ static struct hci_proto sco_hci_proto = { | |||
1023 | .recv_scodata = sco_recv_scodata | 1032 | .recv_scodata = sco_recv_scodata |
1024 | }; | 1033 | }; |
1025 | 1034 | ||
1026 | static int __init sco_init(void) | 1035 | int __init sco_init(void) |
1027 | { | 1036 | { |
1028 | int err; | 1037 | int err; |
1029 | 1038 | ||
@@ -1051,7 +1060,6 @@ static int __init sco_init(void) | |||
1051 | BT_ERR("Failed to create SCO debug file"); | 1060 | BT_ERR("Failed to create SCO debug file"); |
1052 | } | 1061 | } |
1053 | 1062 | ||
1054 | BT_INFO("SCO (Voice Link) ver %s", VERSION); | ||
1055 | BT_INFO("SCO socket layer initialized"); | 1063 | BT_INFO("SCO socket layer initialized"); |
1056 | 1064 | ||
1057 | return 0; | 1065 | return 0; |
@@ -1061,7 +1069,7 @@ error: | |||
1061 | return err; | 1069 | return err; |
1062 | } | 1070 | } |
1063 | 1071 | ||
1064 | static void __exit sco_exit(void) | 1072 | void __exit sco_exit(void) |
1065 | { | 1073 | { |
1066 | debugfs_remove(sco_debugfs); | 1074 | debugfs_remove(sco_debugfs); |
1067 | 1075 | ||
@@ -1074,14 +1082,5 @@ static void __exit sco_exit(void) | |||
1074 | proto_unregister(&sco_proto); | 1082 | proto_unregister(&sco_proto); |
1075 | } | 1083 | } |
1076 | 1084 | ||
1077 | module_init(sco_init); | ||
1078 | module_exit(sco_exit); | ||
1079 | |||
1080 | module_param(disable_esco, bool, 0644); | 1085 | module_param(disable_esco, bool, 0644); |
1081 | MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation"); | 1086 | MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation"); |
1082 | |||
1083 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); | ||
1084 | MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION); | ||
1085 | MODULE_VERSION(VERSION); | ||
1086 | MODULE_LICENSE("GPL"); | ||
1087 | MODULE_ALIAS("bt-proto-2"); | ||