mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masatake YAMATO <yamato@redhat.com>
To: andrei.emeltchenko.news@gmail.com
Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org
Subject: [PATCH v3 6/8] bluetooth: Added /proc/net/l2cap via bt_procfs_init()
Date: Wed, 11 Jul 2012 14:03:37 +0900 (JST)	[thread overview]
Message-ID: <20120711.140337.6492431783697495.yamato@redhat.com> (raw)
In-Reply-To: <20120711.135831.1712662939552441872.yamato@redhat.com>

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 net/bluetooth/l2cap_sock.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index a4bb27e..c9a9f1c 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -34,6 +34,10 @@
 #include <net/bluetooth/l2cap.h>
 #include <net/bluetooth/smp.h>
 
+static struct bt_sock_list l2cap_sk_list = {
+	.lock = __RW_LOCK_UNLOCKED(l2cap_sk_list.lock)
+};
+
 static const struct proto_ops l2cap_sock_ops;
 static void l2cap_sock_init(struct sock *sk, struct sock *parent);
 static 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)
 	if (!sk)
 		return 0;
 
+	bt_sock_unlink(&l2cap_sk_list, sk);
+
 	err = l2cap_sock_shutdown(sock, 2);
 
 	sock_orphan(sk);
@@ -1210,6 +1216,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,
 		return -ENOMEM;
 
 	l2cap_sock_init(sk, NULL);
+	bt_sock_link(&l2cap_sk_list, sk);
 	return 0;
 }
 
@@ -1248,22 +1255,30 @@ int __init l2cap_init_sockets(void)
 		return err;
 
 	err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops);
-	if (err < 0)
+	if (err < 0) {
+		BT_ERR("L2CAP socket registration failed");
 		goto error;
+	}
+
+	err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, NULL);
+	if (err < 0) {
+		BT_ERR("Failed to create L2CAP proc file");
+		bt_sock_unregister(BTPROTO_L2CAP);
+		goto error;
+	}
 
 	BT_INFO("L2CAP socket layer initialized");
 
 	return 0;
 
 error:
-	BT_ERR("L2CAP socket registration failed");
 	proto_unregister(&l2cap_proto);
 	return err;
 }
 
 void l2cap_cleanup_sockets(void)
 {
+	bt_procfs_cleanup(&init_net, "l2cap");
 	if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
 		BT_ERR("L2CAP socket unregistration failed");
 
-- 
1.7.10.4


  parent reply	other threads:[~2012-07-11  5:03 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14 17:15 [PATCH 1/8] /proc/net/ entries for bluetooth protocols Masatake YAMATO
2012-06-15  8:00 ` Andrei Emeltchenko
2012-06-17  0:26   ` Masatake YAMATO
2012-06-18  8:28     ` Andrei Emeltchenko
2012-06-28 17:02       ` Masatake YAMATO
2012-07-10 14:04         ` Andrei Emeltchenko
2012-07-11  4:58           ` [PATCH v3 1/8] bluetooth: " Masatake YAMATO
2012-07-11  4:59             ` [PATCH v3 2/8] bluetooth: Added /proc/net/bnep via bt_procfs_init() Masatake YAMATO
2012-07-25  0:20               ` Gustavo Padovan
2012-07-11  5:02             ` [PATCH v3 3/8] bluetooth: Added /proc/net/cmtp " Masatake YAMATO
2012-07-11  5:02             ` [PATCH v3 4/8] bluetooth: Added /proc/net/hci " Masatake YAMATO
2012-07-11  5:03             ` [PATCH v3 5/8] bluetooth: Added /proc/net/hidp " Masatake YAMATO
2012-07-11  5:03             ` Masatake YAMATO [this message]
2012-07-11  8:48               ` [PATCH v3 6/8] bluetooth: Added /proc/net/l2cap " Andrei Emeltchenko
2012-07-11  9:19                 ` Masatake YAMATO
2012-07-11  9:49                   ` Andrei Emeltchenko
2012-07-11  5:04             ` [PATCH v3 7/8] bluetooth: Added /proc/net/rfcomm " Masatake YAMATO
2012-07-11  8:49               ` Andrei Emeltchenko
2012-07-11  5:04             ` [PATCH v3 8/8] bluetooth: Added /proc/net/sco " Masatake YAMATO
2012-07-11 11:23             ` [PATCH v3 1/8] bluetooth: /proc/net/ entries for bluetooth protocols Andrei Emeltchenko
2012-07-11 12:19               ` Masatake YAMATO
2012-07-12  7:42                 ` Andrei Emeltchenko
2012-07-16 13:20                   ` [PATCH v4 " Masatake YAMATO
2012-07-25  0:12                     ` Gustavo Padovan
2012-07-25  0:35                       ` Gustavo Padovan
2012-07-25 16:26                         ` [PATCH v5 1/8] Bluetooth: " Masatake YAMATO
2012-07-25 16:27                         ` [PATCH v5 2/8] Bluetooth: Added /proc/net/bnep via bt_procfs_init() Masatake YAMATO
2012-07-25 16:28                         ` [PATCH v5 3/8] Bluetooth: Added /proc/net/cmtp " Masatake YAMATO
2012-07-25 16:28                         ` [PATCH v5 4/8] Bluetooth: Added /proc/net/hci " Masatake YAMATO
2012-07-25 16:29                         ` [PATCH v5 5/8] Bluetooth: Added /proc/net/hidp " Masatake YAMATO
2012-07-25 16:29                         ` [PATCH v5 6/8] Bluetooth: Added /proc/net/l2cap " Masatake YAMATO
2012-07-25 16:29                         ` [PATCH v5 7/8] Bluetooth: Added /proc/net/rfcomm " Masatake YAMATO
2012-07-25 16:30                         ` [PATCH v5 8/8] Added /proc/net/sco " Masatake YAMATO
2012-07-26  4:24                           ` Gustavo Padovan
2012-08-15 15:22                             ` Jan Engelhardt
2012-07-24 13:08             ` [PATCH v3 1/8] bluetooth: /proc/net/ entries for bluetooth protocols Masatake YAMATO
2012-07-24 13:15               ` Andrei Emeltchenko
2012-06-18 10:00   ` [PATCH v2 1/8] " Masatake YAMATO
2012-07-10 14:06     ` Andrei Emeltchenko
2012-06-18 10:00   ` [PATCH v2 2/8] Added /proc/net/bnep via bt_procfs_init() Masatake YAMATO
2012-06-18 10:01   ` [PATCH v2 3/8] Added /proc/net/cmtp " Masatake YAMATO
2012-06-18 10:01   ` [PATCH v2 4/8] Added /proc/net/hci " Masatake YAMATO
2012-06-18 10:03   ` [PATCH v2 5/8] Added /proc/net/hidp " Masatake YAMATO
2012-06-18 10:03   ` [PATCH v2 6/8] Added /proc/net/l2cap " Masatake YAMATO
2012-06-18 10:04   ` [PATCH v2 7/8] Added /proc/net/rfcomm " Masatake YAMATO
2012-06-18 10:04   ` [PATCH v2 8/8] Added /proc/net/sco " Masatake YAMATO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120711.140337.6492431783697495.yamato@redhat.com \
    --to=yamato@redhat.com \
    --cc=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®