Commit 5c6ad8ee authored by Masatake YAMATO's avatar Masatake YAMATO Committed by Gustavo Padovan

Bluetooth: Added /proc/net/hidp via bt_procfs_init()

Added /proc/net/hidp via bt_procfs_init().
Signed-off-by: default avatarMasatake YAMATO <yamato@redhat.com>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent f7c86637
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
#include "hidp.h" #include "hidp.h"
static struct bt_sock_list hidp_sk_list = {
.lock = __RW_LOCK_UNLOCKED(hidp_sk_list.lock)
};
static int hidp_sock_release(struct socket *sock) static int hidp_sock_release(struct socket *sock)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -34,6 +38,8 @@ static int hidp_sock_release(struct socket *sock) ...@@ -34,6 +38,8 @@ static int hidp_sock_release(struct socket *sock)
if (!sk) if (!sk)
return 0; return 0;
bt_sock_unlink(&hidp_sk_list, sk);
sock_orphan(sk); sock_orphan(sk);
sock_put(sk); sock_put(sk);
...@@ -253,6 +259,8 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol, ...@@ -253,6 +259,8 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol,
sk->sk_protocol = protocol; sk->sk_protocol = protocol;
sk->sk_state = BT_OPEN; sk->sk_state = BT_OPEN;
bt_sock_link(&hidp_sk_list, sk);
return 0; return 0;
} }
...@@ -271,8 +279,19 @@ int __init hidp_init_sockets(void) ...@@ -271,8 +279,19 @@ int __init hidp_init_sockets(void)
return err; return err;
err = bt_sock_register(BTPROTO_HIDP, &hidp_sock_family_ops); err = bt_sock_register(BTPROTO_HIDP, &hidp_sock_family_ops);
if (err < 0) if (err < 0) {
BT_ERR("Can't register HIDP socket");
goto error; goto error;
}
err = bt_procfs_init(THIS_MODULE, &init_net, "hidp", &hidp_sk_list, NULL);
if (err < 0) {
BT_ERR("Failed to create HIDP proc file");
bt_sock_unregister(BTPROTO_HIDP);
goto error;
}
BT_INFO("HIDP socket layer initialized");
return 0; return 0;
...@@ -284,6 +303,7 @@ int __init hidp_init_sockets(void) ...@@ -284,6 +303,7 @@ int __init hidp_init_sockets(void)
void __exit hidp_cleanup_sockets(void) void __exit hidp_cleanup_sockets(void)
{ {
bt_procfs_cleanup(&init_net, "hidp");
if (bt_sock_unregister(BTPROTO_HIDP) < 0) if (bt_sock_unregister(BTPROTO_HIDP) < 0)
BT_ERR("Can't unregister HIDP socket"); BT_ERR("Can't unregister HIDP socket");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment