Commit 77cf5585 authored by Masatake YAMATO's avatar Masatake YAMATO Committed by Gustavo Padovan

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

Added /proc/net/bnep 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 256a06c8
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
#include "bnep.h" #include "bnep.h"
static struct bt_sock_list bnep_sk_list = {
.lock = __RW_LOCK_UNLOCKED(bnep_sk_list.lock)
};
static int bnep_sock_release(struct socket *sock) static int bnep_sock_release(struct socket *sock)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -38,6 +42,8 @@ static int bnep_sock_release(struct socket *sock) ...@@ -38,6 +42,8 @@ static int bnep_sock_release(struct socket *sock)
if (!sk) if (!sk)
return 0; return 0;
bt_sock_unlink(&bnep_sk_list, sk);
sock_orphan(sk); sock_orphan(sk);
sock_put(sk); sock_put(sk);
return 0; return 0;
...@@ -204,6 +210,7 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol, ...@@ -204,6 +210,7 @@ static int bnep_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(&bnep_sk_list, sk);
return 0; return 0;
} }
...@@ -222,19 +229,30 @@ int __init bnep_sock_init(void) ...@@ -222,19 +229,30 @@ int __init bnep_sock_init(void)
return err; return err;
err = bt_sock_register(BTPROTO_BNEP, &bnep_sock_family_ops); err = bt_sock_register(BTPROTO_BNEP, &bnep_sock_family_ops);
if (err < 0) if (err < 0) {
BT_ERR("Can't register BNEP socket");
goto error; goto error;
}
err = bt_procfs_init(THIS_MODULE, &init_net, "bnep", &bnep_sk_list, NULL);
if (err < 0) {
BT_ERR("Failed to create BNEP proc file");
bt_sock_unregister(BTPROTO_BNEP);
goto error;
}
BT_INFO("BNEP socket layer initialized");
return 0; return 0;
error: error:
BT_ERR("Can't register BNEP socket");
proto_unregister(&bnep_proto); proto_unregister(&bnep_proto);
return err; return err;
} }
void __exit bnep_sock_cleanup(void) void __exit bnep_sock_cleanup(void)
{ {
bt_procfs_cleanup(&init_net, "bnep");
if (bt_sock_unregister(BTPROTO_BNEP) < 0) if (bt_sock_unregister(BTPROTO_BNEP) < 0)
BT_ERR("Can't unregister BNEP socket"); BT_ERR("Can't unregister BNEP 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