aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-11-30 06:17:19 -0500
committerMarcel Holtmann <marcel@holtmann.org>2008-11-30 06:17:19 -0500
commitdb7aa1c203d477351ed1b8f394b40d9df06ddfc4 (patch)
tree7a53a4e408eedca8e9342b7085ffd9de322919e3 /net/bluetooth
parentc6bf514c6e0171c5b731beffaa0c4463e2335f3d (diff)
Bluetooth: Fix warnings for bt_key_strings and bt_slock_key_strings
After adding proper lockdep annotations for Bluetooth protocols the case when lockdep is disabled produced two compiler warnings: net/bluetooth/af_bluetooth.c:60: warning: ‘bt_key_strings’ defined but not used net/bluetooth/af_bluetooth.c:71: warning: ‘bt_slock_key_strings’ defined but not used Fix both of them by adding a CONFIG_DEBUG_LOCK_ALLOC conditional around them and re-arranging the code a little bit. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/af_bluetooth.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 8f9431a12c6f..41f07f549ba7 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -51,8 +51,9 @@
51/* Bluetooth sockets */ 51/* Bluetooth sockets */
52#define BT_MAX_PROTO 8 52#define BT_MAX_PROTO 8
53static struct net_proto_family *bt_proto[BT_MAX_PROTO]; 53static struct net_proto_family *bt_proto[BT_MAX_PROTO];
54static DEFINE_RWLOCK(bt_proto_lock);
54 55
55static struct lock_class_key bt_slock_key[BT_MAX_PROTO]; 56#ifdef CONFIG_DEBUG_LOCK_ALLOC
56static struct lock_class_key bt_lock_key[BT_MAX_PROTO]; 57static struct lock_class_key bt_lock_key[BT_MAX_PROTO];
57static const char *bt_key_strings[BT_MAX_PROTO] = { 58static const char *bt_key_strings[BT_MAX_PROTO] = {
58 "sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP", 59 "sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP",
@@ -65,6 +66,7 @@ static const char *bt_key_strings[BT_MAX_PROTO] = {
65 "sk_lock-AF_BLUETOOTH-BTPROTO_AVDTP", 66 "sk_lock-AF_BLUETOOTH-BTPROTO_AVDTP",
66}; 67};
67 68
69static struct lock_class_key bt_slock_key[BT_MAX_PROTO];
68static const char *bt_slock_key_strings[BT_MAX_PROTO] = { 70static const char *bt_slock_key_strings[BT_MAX_PROTO] = {
69 "slock-AF_BLUETOOTH-BTPROTO_L2CAP", 71 "slock-AF_BLUETOOTH-BTPROTO_L2CAP",
70 "slock-AF_BLUETOOTH-BTPROTO_HCI", 72 "slock-AF_BLUETOOTH-BTPROTO_HCI",
@@ -75,7 +77,25 @@ static const char *bt_slock_key_strings[BT_MAX_PROTO] = {
75 "slock-AF_BLUETOOTH-BTPROTO_HIDP", 77 "slock-AF_BLUETOOTH-BTPROTO_HIDP",
76 "slock-AF_BLUETOOTH-BTPROTO_AVDTP", 78 "slock-AF_BLUETOOTH-BTPROTO_AVDTP",
77}; 79};
78static DEFINE_RWLOCK(bt_proto_lock); 80
81static inline void bt_sock_reclassify_lock(struct socket *sock, int proto)
82{
83 struct sock *sk = sock->sk;
84
85 if (!sk)
86 return;
87
88 BUG_ON(sock_owned_by_user(sk));
89
90 sock_lock_init_class_and_name(sk,
91 bt_slock_key_strings[proto], &bt_slock_key[proto],
92 bt_key_strings[proto], &bt_lock_key[proto]);
93}
94#else
95static inline void bt_sock_reclassify_lock(struct socket *sock, int proto)
96{
97}
98#endif
79 99
80int bt_sock_register(int proto, struct net_proto_family *ops) 100int bt_sock_register(int proto, struct net_proto_family *ops)
81{ 101{
@@ -117,21 +137,6 @@ int bt_sock_unregister(int proto)
117} 137}
118EXPORT_SYMBOL(bt_sock_unregister); 138EXPORT_SYMBOL(bt_sock_unregister);
119 139
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) 140static int bt_sock_create(struct net *net, struct socket *sock, int proto)
136{ 141{
137 int err; 142 int err;
@@ -151,7 +156,7 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto)
151 156
152 if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { 157 if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) {
153 err = bt_proto[proto]->create(net, sock, proto); 158 err = bt_proto[proto]->create(net, sock, proto);
154 bt_reclassify_sock_lock(sock, proto); 159 bt_sock_reclassify_lock(sock, proto);
155 module_put(bt_proto[proto]->owner); 160 module_put(bt_proto[proto]->owner);
156 } 161 }
157 162