diff options
Diffstat (limited to 'net/bluetooth/hidp/sock.c')
-rw-r--r-- | net/bluetooth/hidp/sock.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index b24fb3bd8625..82a829d90b0f 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c | |||
@@ -25,6 +25,10 @@ | |||
25 | 25 | ||
26 | #include "hidp.h" | 26 | #include "hidp.h" |
27 | 27 | ||
28 | static struct bt_sock_list hidp_sk_list = { | ||
29 | .lock = __RW_LOCK_UNLOCKED(hidp_sk_list.lock) | ||
30 | }; | ||
31 | |||
28 | static int hidp_sock_release(struct socket *sock) | 32 | static int hidp_sock_release(struct socket *sock) |
29 | { | 33 | { |
30 | struct sock *sk = sock->sk; | 34 | struct sock *sk = sock->sk; |
@@ -34,6 +38,8 @@ static int hidp_sock_release(struct socket *sock) | |||
34 | if (!sk) | 38 | if (!sk) |
35 | return 0; | 39 | return 0; |
36 | 40 | ||
41 | bt_sock_unlink(&hidp_sk_list, sk); | ||
42 | |||
37 | sock_orphan(sk); | 43 | sock_orphan(sk); |
38 | sock_put(sk); | 44 | sock_put(sk); |
39 | 45 | ||
@@ -253,6 +259,8 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol, | |||
253 | sk->sk_protocol = protocol; | 259 | sk->sk_protocol = protocol; |
254 | sk->sk_state = BT_OPEN; | 260 | sk->sk_state = BT_OPEN; |
255 | 261 | ||
262 | bt_sock_link(&hidp_sk_list, sk); | ||
263 | |||
256 | return 0; | 264 | return 0; |
257 | } | 265 | } |
258 | 266 | ||
@@ -271,8 +279,19 @@ int __init hidp_init_sockets(void) | |||
271 | return err; | 279 | return err; |
272 | 280 | ||
273 | err = bt_sock_register(BTPROTO_HIDP, &hidp_sock_family_ops); | 281 | err = bt_sock_register(BTPROTO_HIDP, &hidp_sock_family_ops); |
274 | if (err < 0) | 282 | if (err < 0) { |
283 | BT_ERR("Can't register HIDP socket"); | ||
275 | goto error; | 284 | goto error; |
285 | } | ||
286 | |||
287 | err = bt_procfs_init(THIS_MODULE, &init_net, "hidp", &hidp_sk_list, NULL); | ||
288 | if (err < 0) { | ||
289 | BT_ERR("Failed to create HIDP proc file"); | ||
290 | bt_sock_unregister(BTPROTO_HIDP); | ||
291 | goto error; | ||
292 | } | ||
293 | |||
294 | BT_INFO("HIDP socket layer initialized"); | ||
276 | 295 | ||
277 | return 0; | 296 | return 0; |
278 | 297 | ||
@@ -284,6 +303,7 @@ error: | |||
284 | 303 | ||
285 | void __exit hidp_cleanup_sockets(void) | 304 | void __exit hidp_cleanup_sockets(void) |
286 | { | 305 | { |
306 | bt_procfs_cleanup(&init_net, "hidp"); | ||
287 | if (bt_sock_unregister(BTPROTO_HIDP) < 0) | 307 | if (bt_sock_unregister(BTPROTO_HIDP) < 0) |
288 | BT_ERR("Can't unregister HIDP socket"); | 308 | BT_ERR("Can't unregister HIDP socket"); |
289 | 309 | ||