aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/af_bluetooth.c50
-rw-r--r--net/bluetooth/bnep/bnep.h2
-rw-r--r--net/bluetooth/bnep/core.c5
-rw-r--r--net/bluetooth/bnep/netdev.c5
-rw-r--r--net/bluetooth/bnep/sock.c5
-rw-r--r--net/bluetooth/cmtp/capi.c5
-rw-r--r--net/bluetooth/cmtp/core.c5
-rw-r--r--net/bluetooth/cmtp/sock.c5
-rw-r--r--net/bluetooth/hci_conn.c5
-rw-r--r--net/bluetooth/hci_core.c11
-rw-r--r--net/bluetooth/hci_event.c5
-rw-r--r--net/bluetooth/hci_sock.c5
-rw-r--r--net/bluetooth/hci_sysfs.c7
-rw-r--r--net/bluetooth/hidp/core.c5
-rw-r--r--net/bluetooth/hidp/sock.c5
-rw-r--r--net/bluetooth/l2cap.c5
-rw-r--r--net/bluetooth/rfcomm/core.c5
-rw-r--r--net/bluetooth/rfcomm/sock.c7
-rw-r--r--net/bluetooth/rfcomm/tty.c35
-rw-r--r--net/bluetooth/sco.c5
20 files changed, 52 insertions, 130 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 8f9431a12c6f..744ed3f07ef3 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -41,18 +41,14 @@
41 41
42#include <net/bluetooth/bluetooth.h> 42#include <net/bluetooth/bluetooth.h>
43 43
44#ifndef CONFIG_BT_SOCK_DEBUG 44#define VERSION "2.14"
45#undef BT_DBG
46#define BT_DBG(D...)
47#endif
48
49#define VERSION "2.13"
50 45
51/* Bluetooth sockets */ 46/* Bluetooth sockets */
52#define BT_MAX_PROTO 8 47#define BT_MAX_PROTO 8
53static struct net_proto_family *bt_proto[BT_MAX_PROTO]; 48static struct net_proto_family *bt_proto[BT_MAX_PROTO];
49static DEFINE_RWLOCK(bt_proto_lock);
54 50
55static struct lock_class_key bt_slock_key[BT_MAX_PROTO]; 51#ifdef CONFIG_DEBUG_LOCK_ALLOC
56static struct lock_class_key bt_lock_key[BT_MAX_PROTO]; 52static struct lock_class_key bt_lock_key[BT_MAX_PROTO];
57static const char *bt_key_strings[BT_MAX_PROTO] = { 53static const char *bt_key_strings[BT_MAX_PROTO] = {
58 "sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP", 54 "sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP",
@@ -65,6 +61,7 @@ static const char *bt_key_strings[BT_MAX_PROTO] = {
65 "sk_lock-AF_BLUETOOTH-BTPROTO_AVDTP", 61 "sk_lock-AF_BLUETOOTH-BTPROTO_AVDTP",
66}; 62};
67 63
64static struct lock_class_key bt_slock_key[BT_MAX_PROTO];
68static const char *bt_slock_key_strings[BT_MAX_PROTO] = { 65static const char *bt_slock_key_strings[BT_MAX_PROTO] = {
69 "slock-AF_BLUETOOTH-BTPROTO_L2CAP", 66 "slock-AF_BLUETOOTH-BTPROTO_L2CAP",
70 "slock-AF_BLUETOOTH-BTPROTO_HCI", 67 "slock-AF_BLUETOOTH-BTPROTO_HCI",
@@ -75,7 +72,25 @@ static const char *bt_slock_key_strings[BT_MAX_PROTO] = {
75 "slock-AF_BLUETOOTH-BTPROTO_HIDP", 72 "slock-AF_BLUETOOTH-BTPROTO_HIDP",
76 "slock-AF_BLUETOOTH-BTPROTO_AVDTP", 73 "slock-AF_BLUETOOTH-BTPROTO_AVDTP",
77}; 74};
78static DEFINE_RWLOCK(bt_proto_lock); 75
76static inline void bt_sock_reclassify_lock(struct socket *sock, int proto)
77{
78 struct sock *sk = sock->sk;
79
80 if (!sk)
81 return;
82
83 BUG_ON(sock_owned_by_user(sk));
84
85 sock_lock_init_class_and_name(sk,
86 bt_slock_key_strings[proto], &bt_slock_key[proto],
87 bt_key_strings[proto], &bt_lock_key[proto]);
88}
89#else
90static inline void bt_sock_reclassify_lock(struct socket *sock, int proto)
91{
92}
93#endif
79 94
80int bt_sock_register(int proto, struct net_proto_family *ops) 95int bt_sock_register(int proto, struct net_proto_family *ops)
81{ 96{
@@ -117,21 +132,6 @@ int bt_sock_unregister(int proto)
117} 132}
118EXPORT_SYMBOL(bt_sock_unregister); 133EXPORT_SYMBOL(bt_sock_unregister);
119 134
120static void bt_reclassify_sock_lock(struct socket *sock, int proto)
121{
122 struct sock *sk = sock->sk;
123
124 if (!sk)
125 return;
126 BUG_ON(sock_owned_by_user(sk));
127
128 sock_lock_init_class_and_name(sk,
129 bt_slock_key_strings[proto],
130 &bt_slock_key[proto],
131 bt_key_strings[proto],
132 &bt_lock_key[proto]);
133}
134
135static int bt_sock_create(struct net *net, struct socket *sock, int proto) 135static int bt_sock_create(struct net *net, struct socket *sock, int proto)
136{ 136{
137 int err; 137 int err;
@@ -151,7 +151,7 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto)
151 151
152 if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { 152 if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) {
153 err = bt_proto[proto]->create(net, sock, proto); 153 err = bt_proto[proto]->create(net, sock, proto);
154 bt_reclassify_sock_lock(sock, proto); 154 bt_sock_reclassify_lock(sock, proto);
155 module_put(bt_proto[proto]->owner); 155 module_put(bt_proto[proto]->owner);
156 } 156 }
157 157
@@ -240,7 +240,7 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
240 size_t copied; 240 size_t copied;
241 int err; 241 int err;
242 242
243 BT_DBG("sock %p sk %p len %d", sock, sk, len); 243 BT_DBG("sock %p sk %p len %zu", sock, sk, len);
244 244
245 if (flags & (MSG_OOB)) 245 if (flags & (MSG_OOB))
246 return -EOPNOTSUPP; 246 return -EOPNOTSUPP;
diff --git a/net/bluetooth/bnep/bnep.h b/net/bluetooth/bnep/bnep.h
index b69bf4e7c48b..d20f8a40f36e 100644
--- a/net/bluetooth/bnep/bnep.h
+++ b/net/bluetooth/bnep/bnep.h
@@ -161,7 +161,7 @@ struct bnep_session {
161 struct msghdr msg; 161 struct msghdr msg;
162 162
163 struct bnep_proto_filter proto_filter[BNEP_MAX_PROTO_FILTERS]; 163 struct bnep_proto_filter proto_filter[BNEP_MAX_PROTO_FILTERS];
164 u64 mc_filter; 164 unsigned long long mc_filter;
165 165
166 struct socket *sock; 166 struct socket *sock;
167 struct net_device *dev; 167 struct net_device *dev;
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index f8efaf35293c..70fea8bdb4e5 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -52,11 +52,6 @@
52 52
53#include "bnep.h" 53#include "bnep.h"
54 54
55#ifndef CONFIG_BT_BNEP_DEBUG
56#undef BT_DBG
57#define BT_DBG(D...)
58#endif
59
60#define VERSION "1.3" 55#define VERSION "1.3"
61 56
62static int compress_src = 1; 57static int compress_src = 1;
diff --git a/net/bluetooth/bnep/netdev.c b/net/bluetooth/bnep/netdev.c
index 47e179f62e82..f897da6e0444 100644
--- a/net/bluetooth/bnep/netdev.c
+++ b/net/bluetooth/bnep/netdev.c
@@ -41,11 +41,6 @@
41 41
42#include "bnep.h" 42#include "bnep.h"
43 43
44#ifndef CONFIG_BT_BNEP_DEBUG
45#undef BT_DBG
46#define BT_DBG( A... )
47#endif
48
49#define BNEP_TX_QUEUE_LEN 20 44#define BNEP_TX_QUEUE_LEN 20
50 45
51static int bnep_net_open(struct net_device *dev) 46static int bnep_net_open(struct net_device *dev)
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c
index 8ffb57f2303a..e857628b0b27 100644
--- a/net/bluetooth/bnep/sock.c
+++ b/net/bluetooth/bnep/sock.c
@@ -46,11 +46,6 @@
46 46
47#include "bnep.h" 47#include "bnep.h"
48 48
49#ifndef CONFIG_BT_BNEP_DEBUG
50#undef BT_DBG
51#define BT_DBG( A... )
52#endif
53
54static int bnep_sock_release(struct socket *sock) 49static int bnep_sock_release(struct socket *sock)
55{ 50{
56 struct sock *sk = sock->sk; 51 struct sock *sk = sock->sk;
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index 3e9d5bb3fefb..78958c0f9a40 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -42,11 +42,6 @@
42 42
43#include "cmtp.h" 43#include "cmtp.h"
44 44
45#ifndef CONFIG_BT_CMTP_DEBUG
46#undef BT_DBG
47#define BT_DBG(D...)
48#endif
49
50#define CAPI_INTEROPERABILITY 0x20 45#define CAPI_INTEROPERABILITY 0x20
51 46
52#define CAPI_INTEROPERABILITY_REQ CAPICMD(CAPI_INTEROPERABILITY, CAPI_REQ) 47#define CAPI_INTEROPERABILITY_REQ CAPICMD(CAPI_INTEROPERABILITY, CAPI_REQ)
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index ca60a4517fd3..c9cac7719efe 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -44,11 +44,6 @@
44 44
45#include "cmtp.h" 45#include "cmtp.h"
46 46
47#ifndef CONFIG_BT_CMTP_DEBUG
48#undef BT_DBG
49#define BT_DBG(D...)
50#endif
51
52#define VERSION "1.0" 47#define VERSION "1.0"
53 48
54static DECLARE_RWSEM(cmtp_session_sem); 49static DECLARE_RWSEM(cmtp_session_sem);
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c
index 8c7f7bc4e0ba..16b0fad74f6e 100644
--- a/net/bluetooth/cmtp/sock.c
+++ b/net/bluetooth/cmtp/sock.c
@@ -43,11 +43,6 @@
43 43
44#include "cmtp.h" 44#include "cmtp.h"
45 45
46#ifndef CONFIG_BT_CMTP_DEBUG
47#undef BT_DBG
48#define BT_DBG(D...)
49#endif
50
51static int cmtp_sock_release(struct socket *sock) 46static int cmtp_sock_release(struct socket *sock)
52{ 47{
53 struct sock *sk = sock->sk; 48 struct sock *sk = sock->sk;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index b7002429f152..a4a789f24c8d 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -45,11 +45,6 @@
45#include <net/bluetooth/bluetooth.h> 45#include <net/bluetooth/bluetooth.h>
46#include <net/bluetooth/hci_core.h> 46#include <net/bluetooth/hci_core.h>
47 47
48#ifndef CONFIG_BT_HCI_CORE_DEBUG
49#undef BT_DBG
50#define BT_DBG(D...)
51#endif
52
53void hci_acl_connect(struct hci_conn *conn) 48void hci_acl_connect(struct hci_conn *conn)
54{ 49{
55 struct hci_dev *hdev = conn->hdev; 50 struct hci_dev *hdev = conn->hdev;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 278a3ace14f6..ba78cc1eb8d9 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -48,11 +48,6 @@
48#include <net/bluetooth/bluetooth.h> 48#include <net/bluetooth/bluetooth.h>
49#include <net/bluetooth/hci_core.h> 49#include <net/bluetooth/hci_core.h>
50 50
51#ifndef CONFIG_BT_HCI_CORE_DEBUG
52#undef BT_DBG
53#define BT_DBG(D...)
54#endif
55
56static void hci_cmd_task(unsigned long arg); 51static void hci_cmd_task(unsigned long arg);
57static void hci_rx_task(unsigned long arg); 52static void hci_rx_task(unsigned long arg);
58static void hci_tx_task(unsigned long arg); 53static void hci_tx_task(unsigned long arg);
@@ -205,7 +200,7 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
205 /* Mandatory initialization */ 200 /* Mandatory initialization */
206 201
207 /* Reset */ 202 /* Reset */
208 if (test_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks)) 203 if (!test_bit(HCI_QUIRK_NO_RESET, &hdev->quirks))
209 hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL); 204 hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL);
210 205
211 /* Read Local Supported Features */ 206 /* Read Local Supported Features */
@@ -290,7 +285,7 @@ static void hci_linkpol_req(struct hci_dev *hdev, unsigned long opt)
290{ 285{
291 __le16 policy = cpu_to_le16(opt); 286 __le16 policy = cpu_to_le16(opt);
292 287
293 BT_DBG("%s %x", hdev->name, opt); 288 BT_DBG("%s %x", hdev->name, policy);
294 289
295 /* Default link policy */ 290 /* Default link policy */
296 hci_send_cmd(hdev, HCI_OP_WRITE_DEF_LINK_POLICY, 2, &policy); 291 hci_send_cmd(hdev, HCI_OP_WRITE_DEF_LINK_POLICY, 2, &policy);
@@ -756,7 +751,7 @@ int hci_get_dev_list(void __user *arg)
756 751
757 size = sizeof(*dl) + dev_num * sizeof(*dr); 752 size = sizeof(*dl) + dev_num * sizeof(*dr);
758 753
759 if (!(dl = kmalloc(size, GFP_KERNEL))) 754 if (!(dl = kzalloc(size, GFP_KERNEL)))
760 return -ENOMEM; 755 return -ENOMEM;
761 756
762 dr = dl->dev_req; 757 dr = dl->dev_req;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index ad7a553d7713..f91ba690f5d2 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -45,11 +45,6 @@
45#include <net/bluetooth/bluetooth.h> 45#include <net/bluetooth/bluetooth.h>
46#include <net/bluetooth/hci_core.h> 46#include <net/bluetooth/hci_core.h>
47 47
48#ifndef CONFIG_BT_HCI_CORE_DEBUG
49#undef BT_DBG
50#define BT_DBG(D...)
51#endif
52
53/* Handle HCI Event packets */ 48/* Handle HCI Event packets */
54 49
55static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) 50static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index d62579b67959..4f9621f759a0 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -49,11 +49,6 @@
49#include <net/bluetooth/bluetooth.h> 49#include <net/bluetooth/bluetooth.h>
50#include <net/bluetooth/hci_core.h> 50#include <net/bluetooth/hci_core.h>
51 51
52#ifndef CONFIG_BT_HCI_SOCK_DEBUG
53#undef BT_DBG
54#define BT_DBG(D...)
55#endif
56
57/* ----- HCI socket interface ----- */ 52/* ----- HCI socket interface ----- */
58 53
59static inline int hci_test_bit(int nr, void *addr) 54static inline int hci_test_bit(int nr, void *addr)
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index f2bbb2f65434..1a1f916be44e 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -6,11 +6,6 @@
6#include <net/bluetooth/bluetooth.h> 6#include <net/bluetooth/bluetooth.h>
7#include <net/bluetooth/hci_core.h> 7#include <net/bluetooth/hci_core.h>
8 8
9#ifndef CONFIG_BT_HCI_CORE_DEBUG
10#undef BT_DBG
11#define BT_DBG(D...)
12#endif
13
14struct class *bt_class = NULL; 9struct class *bt_class = NULL;
15EXPORT_SYMBOL_GPL(bt_class); 10EXPORT_SYMBOL_GPL(bt_class);
16 11
@@ -420,7 +415,7 @@ int hci_register_sysfs(struct hci_dev *hdev)
420 dev->class = bt_class; 415 dev->class = bt_class;
421 dev->parent = hdev->parent; 416 dev->parent = hdev->parent;
422 417
423 dev_set_name(dev, hdev->name); 418 dev_set_name(dev, "%s", hdev->name);
424 419
425 dev_set_drvdata(dev, hdev); 420 dev_set_drvdata(dev, hdev);
426 421
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index acdeab3d9807..b18676870d55 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -47,11 +47,6 @@
47 47
48#include "hidp.h" 48#include "hidp.h"
49 49
50#ifndef CONFIG_BT_HIDP_DEBUG
51#undef BT_DBG
52#define BT_DBG(D...)
53#endif
54
55#define VERSION "1.2" 50#define VERSION "1.2"
56 51
57static DECLARE_RWSEM(hidp_session_sem); 52static DECLARE_RWSEM(hidp_session_sem);
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c
index f4dd02ca9a96..37c9d7d2e688 100644
--- a/net/bluetooth/hidp/sock.c
+++ b/net/bluetooth/hidp/sock.c
@@ -39,11 +39,6 @@
39 39
40#include "hidp.h" 40#include "hidp.h"
41 41
42#ifndef CONFIG_BT_HIDP_DEBUG
43#undef BT_DBG
44#define BT_DBG(D...)
45#endif
46
47static int hidp_sock_release(struct socket *sock) 42static int hidp_sock_release(struct socket *sock)
48{ 43{
49 struct sock *sk = sock->sk; 44 struct sock *sk = sock->sk;
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 9610a9c85b98..b93748e224ff 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -50,11 +50,6 @@
50#include <net/bluetooth/hci_core.h> 50#include <net/bluetooth/hci_core.h>
51#include <net/bluetooth/l2cap.h> 51#include <net/bluetooth/l2cap.h>
52 52
53#ifndef CONFIG_BT_L2CAP_DEBUG
54#undef BT_DBG
55#define BT_DBG(D...)
56#endif
57
58#define VERSION "2.11" 53#define VERSION "2.11"
59 54
60static u32 l2cap_feat_mask = 0x0000; 55static u32 l2cap_feat_mask = 0x0000;
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index ba537fae0a4c..37c640d1c3fd 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -46,11 +46,6 @@
46#include <net/bluetooth/l2cap.h> 46#include <net/bluetooth/l2cap.h>
47#include <net/bluetooth/rfcomm.h> 47#include <net/bluetooth/rfcomm.h>
48 48
49#ifndef CONFIG_BT_RFCOMM_DEBUG
50#undef BT_DBG
51#define BT_DBG(D...)
52#endif
53
54#define VERSION "1.10" 49#define VERSION "1.10"
55 50
56static int disable_cfc = 0; 51static int disable_cfc = 0;
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index bc0d4a7ce6ae..ad00cbf449cb 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -50,11 +50,6 @@
50#include <net/bluetooth/l2cap.h> 50#include <net/bluetooth/l2cap.h>
51#include <net/bluetooth/rfcomm.h> 51#include <net/bluetooth/rfcomm.h>
52 52
53#ifndef CONFIG_BT_RFCOMM_DEBUG
54#undef BT_DBG
55#define BT_DBG(D...)
56#endif
57
58static const struct proto_ops rfcomm_sock_ops; 53static const struct proto_ops rfcomm_sock_ops;
59 54
60static struct bt_sock_list rfcomm_sk_list = { 55static struct bt_sock_list rfcomm_sk_list = {
@@ -644,7 +639,7 @@ static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
644 639
645 msg->msg_namelen = 0; 640 msg->msg_namelen = 0;
646 641
647 BT_DBG("sk %p size %d", sk, size); 642 BT_DBG("sk %p size %zu", sk, size);
648 643
649 lock_sock(sk); 644 lock_sock(sk);
650 645
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index d3340dd52bcf..111c6c858247 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -39,11 +39,6 @@
39#include <net/bluetooth/hci_core.h> 39#include <net/bluetooth/hci_core.h>
40#include <net/bluetooth/rfcomm.h> 40#include <net/bluetooth/rfcomm.h>
41 41
42#ifndef CONFIG_BT_RFCOMM_DEBUG
43#undef BT_DBG
44#define BT_DBG(D...)
45#endif
46
47#define RFCOMM_TTY_MAGIC 0x6d02 /* magic number for rfcomm struct */ 42#define RFCOMM_TTY_MAGIC 0x6d02 /* magic number for rfcomm struct */
48#define RFCOMM_TTY_PORTS RFCOMM_MAX_DEV /* whole lotta rfcomm devices */ 43#define RFCOMM_TTY_PORTS RFCOMM_MAX_DEV /* whole lotta rfcomm devices */
49#define RFCOMM_TTY_MAJOR 216 /* device node major id of the usb/bluetooth.c driver */ 44#define RFCOMM_TTY_MAJOR 216 /* device node major id of the usb/bluetooth.c driver */
@@ -58,7 +53,7 @@ struct rfcomm_dev {
58 char name[12]; 53 char name[12];
59 int id; 54 int id;
60 unsigned long flags; 55 unsigned long flags;
61 int opened; 56 atomic_t opened;
62 int err; 57 int err;
63 58
64 bdaddr_t src; 59 bdaddr_t src;
@@ -261,6 +256,8 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
261 dev->flags = req->flags & 256 dev->flags = req->flags &
262 ((1 << RFCOMM_RELEASE_ONHUP) | (1 << RFCOMM_REUSE_DLC)); 257 ((1 << RFCOMM_RELEASE_ONHUP) | (1 << RFCOMM_REUSE_DLC));
263 258
259 atomic_set(&dev->opened, 0);
260
264 init_waitqueue_head(&dev->wait); 261 init_waitqueue_head(&dev->wait);
265 tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev); 262 tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev);
266 263
@@ -330,10 +327,10 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
330{ 327{
331 BT_DBG("dev %p", dev); 328 BT_DBG("dev %p", dev);
332 329
333 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) 330 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
334 BUG_ON(1); 331
335 else 332 if (atomic_read(&dev->opened) > 0)
336 set_bit(RFCOMM_TTY_RELEASED, &dev->flags); 333 return;
337 334
338 write_lock_bh(&rfcomm_dev_lock); 335 write_lock_bh(&rfcomm_dev_lock);
339 list_del_init(&dev->list); 336 list_del_init(&dev->list);
@@ -689,9 +686,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
689 if (!dev) 686 if (!dev)
690 return -ENODEV; 687 return -ENODEV;
691 688
692 BT_DBG("dev %p dst %s channel %d opened %d", dev, batostr(&dev->dst), dev->channel, dev->opened); 689 BT_DBG("dev %p dst %s channel %d opened %d", dev, batostr(&dev->dst),
690 dev->channel, atomic_read(&dev->opened));
693 691
694 if (dev->opened++ != 0) 692 if (atomic_inc_return(&dev->opened) > 1)
695 return 0; 693 return 0;
696 694
697 dlc = dev->dlc; 695 dlc = dev->dlc;
@@ -747,9 +745,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
747 if (!dev) 745 if (!dev)
748 return; 746 return;
749 747
750 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, dev->opened); 748 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
749 atomic_read(&dev->opened));
751 750
752 if (--dev->opened == 0) { 751 if (atomic_dec_and_test(&dev->opened)) {
753 if (dev->tty_dev->parent) 752 if (dev->tty_dev->parent)
754 device_move(dev->tty_dev, NULL); 753 device_move(dev->tty_dev, NULL);
755 754
@@ -763,6 +762,14 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
763 tty->driver_data = NULL; 762 tty->driver_data = NULL;
764 dev->tty = NULL; 763 dev->tty = NULL;
765 rfcomm_dlc_unlock(dev->dlc); 764 rfcomm_dlc_unlock(dev->dlc);
765
766 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) {
767 write_lock_bh(&rfcomm_dev_lock);
768 list_del_init(&dev->list);
769 write_unlock_bh(&rfcomm_dev_lock);
770
771 rfcomm_dev_put(dev);
772 }
766 } 773 }
767 774
768 rfcomm_dev_put(dev); 775 rfcomm_dev_put(dev);
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 0cc91e6da76d..46fd8bf9a690 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -48,11 +48,6 @@
48#include <net/bluetooth/hci_core.h> 48#include <net/bluetooth/hci_core.h>
49#include <net/bluetooth/sco.h> 49#include <net/bluetooth/sco.h>
50 50
51#ifndef CONFIG_BT_SCO_DEBUG
52#undef BT_DBG
53#define BT_DBG(D...)
54#endif
55
56#define VERSION "0.6" 51#define VERSION "0.6"
57 52
58static int disable_esco = 0; 53static int disable_esco = 0;