aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/l2cap_sock.c
diff options
context:
space:
mode:
authorMasatake YAMATO <yamato@redhat.com>2012-07-25 12:29:25 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-08-06 14:02:59 -0400
commit5b28d95c13e876037d2c692e61862bb3e98249af (patch)
tree63c44bd4b35c08affe1da420495dffd3b2b838e1 /net/bluetooth/l2cap_sock.c
parent5c6ad8eee0a8c5fb4ba8b741008490da9eb66af6 (diff)
Bluetooth: Added /proc/net/l2cap via bt_procfs_init()
Added /proc/net/l2cap via bt_procfs_init(). Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/l2cap_sock.c')
-rw-r--r--net/bluetooth/l2cap_sock.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 79350d10087c..13f6a9816feb 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -34,6 +34,10 @@
34#include <net/bluetooth/l2cap.h> 34#include <net/bluetooth/l2cap.h>
35#include <net/bluetooth/smp.h> 35#include <net/bluetooth/smp.h>
36 36
37static struct bt_sock_list l2cap_sk_list = {
38 .lock = __RW_LOCK_UNLOCKED(l2cap_sk_list.lock)
39};
40
37static const struct proto_ops l2cap_sock_ops; 41static const struct proto_ops l2cap_sock_ops;
38static void l2cap_sock_init(struct sock *sk, struct sock *parent); 42static void l2cap_sock_init(struct sock *sk, struct sock *parent);
39static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio); 43static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio);
@@ -886,6 +890,8 @@ static int l2cap_sock_release(struct socket *sock)
886 if (!sk) 890 if (!sk)
887 return 0; 891 return 0;
888 892
893 bt_sock_unlink(&l2cap_sk_list, sk);
894
889 err = l2cap_sock_shutdown(sock, 2); 895 err = l2cap_sock_shutdown(sock, 2);
890 896
891 sock_orphan(sk); 897 sock_orphan(sk);
@@ -1210,6 +1216,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,
1210 return -ENOMEM; 1216 return -ENOMEM;
1211 1217
1212 l2cap_sock_init(sk, NULL); 1218 l2cap_sock_init(sk, NULL);
1219 bt_sock_link(&l2cap_sk_list, sk);
1213 return 0; 1220 return 0;
1214} 1221}
1215 1222
@@ -1248,21 +1255,30 @@ int __init l2cap_init_sockets(void)
1248 return err; 1255 return err;
1249 1256
1250 err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops); 1257 err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops);
1251 if (err < 0) 1258 if (err < 0) {
1259 BT_ERR("L2CAP socket registration failed");
1252 goto error; 1260 goto error;
1261 }
1262
1263 err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, NULL);
1264 if (err < 0) {
1265 BT_ERR("Failed to create L2CAP proc file");
1266 bt_sock_unregister(BTPROTO_L2CAP);
1267 goto error;
1268 }
1253 1269
1254 BT_INFO("L2CAP socket layer initialized"); 1270 BT_INFO("L2CAP socket layer initialized");
1255 1271
1256 return 0; 1272 return 0;
1257 1273
1258error: 1274error:
1259 BT_ERR("L2CAP socket registration failed");
1260 proto_unregister(&l2cap_proto); 1275 proto_unregister(&l2cap_proto);
1261 return err; 1276 return err;
1262} 1277}
1263 1278
1264void l2cap_cleanup_sockets(void) 1279void l2cap_cleanup_sockets(void)
1265{ 1280{
1281 bt_procfs_cleanup(&init_net, "l2cap");
1266 if (bt_sock_unregister(BTPROTO_L2CAP) < 0) 1282 if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
1267 BT_ERR("L2CAP socket unregistration failed"); 1283 BT_ERR("L2CAP socket unregistration failed");
1268 1284