aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-12-28 15:49:40 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-12-28 15:49:40 -0500
commit0191b625ca5a46206d2fb862bb08f36f2fcb3b31 (patch)
tree454d1842b1833d976da62abcbd5c47521ebe9bd7 /net/bluetooth
parent54a696bd07c14d3b1192d03ce7269bc59b45209a (diff)
parenteb56092fc168bf5af199d47af50c0d84a96db898 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1429 commits) net: Allow dependancies of FDDI & Tokenring to be modular. igb: Fix build warning when DCA is disabled. net: Fix warning fallout from recent NAPI interface changes. gro: Fix potential use after free sfc: If AN is enabled, always read speed/duplex from the AN advertising bits sfc: When disabling the NIC, close the device rather than unregistering it sfc: SFT9001: Add cable diagnostics sfc: Add support for multiple PHY self-tests sfc: Merge top-level functions for self-tests sfc: Clean up PHY mode management in loopback self-test sfc: Fix unreliable link detection in some loopback modes sfc: Generate unique names for per-NIC workqueues 802.3ad: use standard ethhdr instead of ad_header 802.3ad: generalize out mac address initializer 802.3ad: initialize ports LACPDU from const initializer 802.3ad: remove typedef around ad_system 802.3ad: turn ports is_individual into a bool 802.3ad: turn ports is_enabled into a bool 802.3ad: make ntt bool ixgbe: Fix set_ringparam in ixgbe to use the same memory pools. ... Fixed trivial IPv4/6 address printing conflicts in fs/cifs/connect.c due to the conversion to %pI (in this networking merge) and the addition of doing IPv6 addresses (from the earlier merge of CIFS).
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/af_bluetooth.c50
-rw-r--r--net/bluetooth/bnep/bnep.h2
-rw-r--r--net/bluetooth/bnep/core.c8
-rw-r--r--net/bluetooth/bnep/netdev.c11
-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.c12
-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.c9
-rw-r--r--net/bluetooth/rfcomm/tty.c48
-rw-r--r--net/bluetooth/sco.c5
20 files changed, 66 insertions, 145 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 80ba30cf4b68..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;
@@ -311,7 +306,6 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
311 struct sk_buff *nskb; 306 struct sk_buff *nskb;
312 u8 type; 307 u8 type;
313 308
314 dev->last_rx = jiffies;
315 s->stats.rx_bytes += skb->len; 309 s->stats.rx_bytes += skb->len;
316 310
317 type = *(u8 *) skb->data; skb_pull(skb, 1); 311 type = *(u8 *) skb->data; skb_pull(skb, 1);
@@ -566,7 +560,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
566 goto failed; 560 goto failed;
567 } 561 }
568 562
569 s = dev->priv; 563 s = netdev_priv(dev);
570 564
571 /* This is rx header therefore addresses are swapped. 565 /* This is rx header therefore addresses are swapped.
572 * ie eh.h_dest is our local address. */ 566 * ie eh.h_dest is our local address. */
diff --git a/net/bluetooth/bnep/netdev.c b/net/bluetooth/bnep/netdev.c
index d9fa0ab2c87f..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)
@@ -62,14 +57,14 @@ static int bnep_net_close(struct net_device *dev)
62 57
63static struct net_device_stats *bnep_net_get_stats(struct net_device *dev) 58static struct net_device_stats *bnep_net_get_stats(struct net_device *dev)
64{ 59{
65 struct bnep_session *s = dev->priv; 60 struct bnep_session *s = netdev_priv(dev);
66 return &s->stats; 61 return &s->stats;
67} 62}
68 63
69static void bnep_net_set_mc_list(struct net_device *dev) 64static void bnep_net_set_mc_list(struct net_device *dev)
70{ 65{
71#ifdef CONFIG_BT_BNEP_MC_FILTER 66#ifdef CONFIG_BT_BNEP_MC_FILTER
72 struct bnep_session *s = dev->priv; 67 struct bnep_session *s = netdev_priv(dev);
73 struct sock *sk = s->sock->sk; 68 struct sock *sk = s->sock->sk;
74 struct bnep_set_filter_req *r; 69 struct bnep_set_filter_req *r;
75 struct sk_buff *skb; 70 struct sk_buff *skb;
@@ -183,7 +178,7 @@ static inline int bnep_net_proto_filter(struct sk_buff *skb, struct bnep_session
183 178
184static int bnep_net_xmit(struct sk_buff *skb, struct net_device *dev) 179static int bnep_net_xmit(struct sk_buff *skb, struct net_device *dev)
185{ 180{
186 struct bnep_session *s = dev->priv; 181 struct bnep_session *s = netdev_priv(dev);
187 struct sock *sk = s->sock->sk; 182 struct sock *sk = s->sock->sk;
188 183
189 BT_DBG("skb %p, dev %p", skb, dev); 184 BT_DBG("skb %p, dev %p", skb, 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 f4f6615cad9f..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
@@ -113,8 +108,7 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
113 conn->dev.class = bt_class; 108 conn->dev.class = bt_class;
114 conn->dev.parent = &hdev->dev; 109 conn->dev.parent = &hdev->dev;
115 110
116 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "%s:%d", 111 dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle);
117 hdev->name, conn->handle);
118 112
119 dev_set_drvdata(&conn->dev, conn); 113 dev_set_drvdata(&conn->dev, conn);
120 114
@@ -132,7 +126,7 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
132 */ 126 */
133static int __match_tty(struct device *dev, void *data) 127static int __match_tty(struct device *dev, void *data)
134{ 128{
135 return !strncmp(dev->bus_id, "rfcomm", 6); 129 return !strncmp(dev_name(dev), "rfcomm", 6);
136} 130}
137 131
138static void del_conn(struct work_struct *work) 132static void del_conn(struct work_struct *work)
@@ -421,7 +415,7 @@ int hci_register_sysfs(struct hci_dev *hdev)
421 dev->class = bt_class; 415 dev->class = bt_class;
422 dev->parent = hdev->parent; 416 dev->parent = hdev->parent;
423 417
424 strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE); 418 dev_set_name(dev, "%s", hdev->name);
425 419
426 dev_set_drvdata(dev, hdev); 420 dev_set_drvdata(dev, hdev);
427 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 ce68e046d963..acd84fd524b8 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 8a972b6ba85f..d3fc6fca38d0 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
@@ -792,7 +787,7 @@ static int rfcomm_sock_getsockopt(struct socket *sock, int level, int optname, c
792 787
793static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 788static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
794{ 789{
795 struct sock *sk = sock->sk; 790 struct sock *sk __maybe_unused = sock->sk;
796 int err; 791 int err;
797 792
798 BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg); 793 BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg);
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index d3340dd52bcf..d030c69cb5a3 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
@@ -301,18 +298,15 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
301out: 298out:
302 write_unlock_bh(&rfcomm_dev_lock); 299 write_unlock_bh(&rfcomm_dev_lock);
303 300
304 if (err < 0) { 301 if (err < 0)
305 kfree(dev); 302 goto free;
306 return err;
307 }
308 303
309 dev->tty_dev = tty_register_device(rfcomm_tty_driver, dev->id, NULL); 304 dev->tty_dev = tty_register_device(rfcomm_tty_driver, dev->id, NULL);
310 305
311 if (IS_ERR(dev->tty_dev)) { 306 if (IS_ERR(dev->tty_dev)) {
312 err = PTR_ERR(dev->tty_dev); 307 err = PTR_ERR(dev->tty_dev);
313 list_del(&dev->list); 308 list_del(&dev->list);
314 kfree(dev); 309 goto free;
315 return err;
316 } 310 }
317 311
318 dev_set_drvdata(dev->tty_dev, dev); 312 dev_set_drvdata(dev->tty_dev, dev);
@@ -324,16 +318,20 @@ out:
324 BT_ERR("Failed to create channel attribute"); 318 BT_ERR("Failed to create channel attribute");
325 319
326 return dev->id; 320 return dev->id;
321
322free:
323 kfree(dev);
324 return err;
327} 325}
328 326
329static void rfcomm_dev_del(struct rfcomm_dev *dev) 327static void rfcomm_dev_del(struct rfcomm_dev *dev)
330{ 328{
331 BT_DBG("dev %p", dev); 329 BT_DBG("dev %p", dev);
332 330
333 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) 331 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
334 BUG_ON(1); 332
335 else 333 if (atomic_read(&dev->opened) > 0)
336 set_bit(RFCOMM_TTY_RELEASED, &dev->flags); 334 return;
337 335
338 write_lock_bh(&rfcomm_dev_lock); 336 write_lock_bh(&rfcomm_dev_lock);
339 list_del_init(&dev->list); 337 list_del_init(&dev->list);
@@ -689,9 +687,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
689 if (!dev) 687 if (!dev)
690 return -ENODEV; 688 return -ENODEV;
691 689
692 BT_DBG("dev %p dst %s channel %d opened %d", dev, batostr(&dev->dst), dev->channel, dev->opened); 690 BT_DBG("dev %p dst %s channel %d opened %d", dev, batostr(&dev->dst),
691 dev->channel, atomic_read(&dev->opened));
693 692
694 if (dev->opened++ != 0) 693 if (atomic_inc_return(&dev->opened) > 1)
695 return 0; 694 return 0;
696 695
697 dlc = dev->dlc; 696 dlc = dev->dlc;
@@ -747,9 +746,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
747 if (!dev) 746 if (!dev)
748 return; 747 return;
749 748
750 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, dev->opened); 749 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
750 atomic_read(&dev->opened));
751 751
752 if (--dev->opened == 0) { 752 if (atomic_dec_and_test(&dev->opened)) {
753 if (dev->tty_dev->parent) 753 if (dev->tty_dev->parent)
754 device_move(dev->tty_dev, NULL); 754 device_move(dev->tty_dev, NULL);
755 755
@@ -763,6 +763,14 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
763 tty->driver_data = NULL; 763 tty->driver_data = NULL;
764 dev->tty = NULL; 764 dev->tty = NULL;
765 rfcomm_dlc_unlock(dev->dlc); 765 rfcomm_dlc_unlock(dev->dlc);
766
767 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) {
768 write_lock_bh(&rfcomm_dev_lock);
769 list_del_init(&dev->list);
770 write_unlock_bh(&rfcomm_dev_lock);
771
772 rfcomm_dev_put(dev);
773 }
766 } 774 }
767 775
768 rfcomm_dev_put(dev); 776 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;