Linux bluetooth development
 help / color / mirror / Atom feed
From: Gustavo Padovan <gustavo@padovan.org>
To: linux-bluetooth@vger.kernel.org
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Subject: [PATCH 03/12] Bluetooth: Add l2cap_chan->ops->ready()
Date: Thu, 24 May 2012 19:59:43 -0300	[thread overview]
Message-ID: <1337900389-30915-3-git-send-email-gustavo@padovan.org> (raw)
In-Reply-To: <1337900389-30915-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

This move socket specific code to l2cap_sock.c.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 include/net/bluetooth/l2cap.h |    1 +
 net/bluetooth/l2cap_core.c    |   18 +++---------------
 net/bluetooth/l2cap_sock.c    |   21 +++++++++++++++++++++
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index be3ce5a..fac6996 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -530,6 +530,7 @@ struct l2cap_ops {
 	void			(*state_change) (void *data, int state);
 	struct sk_buff		*(*alloc_skb) (struct l2cap_chan *chan,
 					       unsigned long len, int nb);
+	void			(*ready) (void *data);
 };
 
 struct l2cap_conn {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 9f5fc4f..b808955 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -931,26 +931,14 @@ static void l2cap_send_conn_req(struct l2cap_chan *chan)
 
 static void l2cap_chan_ready(struct l2cap_chan *chan)
 {
-	struct sock *sk = chan->sk;
-	struct sock *parent;
-
-	lock_sock(sk);
-
-	parent = bt_sk(sk)->parent;
-
-	BT_DBG("sk %p, parent %p", sk, parent);
-
 	/* This clears all conf flags, including CONF_NOT_COMPLETE */
 	chan->conf_state = 0;
 	__clear_chan_timer(chan);
 
-	__l2cap_state_change(chan, BT_CONNECTED);
-	sk->sk_state_change(sk);
-
-	if (parent)
-		parent->sk_data_ready(parent, 0);
+	chan->state = BT_CONNECTED;
 
-	release_sock(sk);
+	if (chan->ops->ready)
+		chan->ops->ready(chan->data);
 }
 
 static void l2cap_do_start(struct l2cap_chan *chan)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index c5a1b57..6730905 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1016,6 +1016,26 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
 	return skb;
 }
 
+static void l2cap_sock_ready_cb(void *data)
+{
+	struct sock *sk = data;
+	struct sock *parent;
+
+	lock_sock(sk);
+
+	parent = bt_sk(sk)->parent;
+
+	BT_DBG("sk %p, parent %p", sk, parent);
+
+	sk->sk_state = BT_CONNECTED;
+	sk->sk_state_change(sk);
+
+	if (parent)
+		parent->sk_data_ready(parent, 0);
+
+	release_sock(sk);
+}
+
 static struct l2cap_ops l2cap_chan_ops = {
 	.name		= "L2CAP Socket Interface",
 	.new_connection	= l2cap_sock_new_connection_cb,
@@ -1024,6 +1044,7 @@ static struct l2cap_ops l2cap_chan_ops = {
 	.teardown	= l2cap_sock_teardown_cb,
 	.state_change	= l2cap_sock_state_change_cb,
 	.alloc_skb	= l2cap_sock_alloc_skb_cb,
+	.ready		= l2cap_sock_ready_cb,
 };
 
 static void l2cap_sock_destruct(struct sock *sk)
-- 
1.7.10.1


  parent reply	other threads:[~2012-05-24 22:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
2012-05-24 22:59 ` [PATCH 02/12] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Gustavo Padovan
2012-05-24 22:59 ` Gustavo Padovan [this message]
2012-05-24 22:59 ` [PATCH 04/12] Bluetooth: Use l2cap_chan_ready() in LE path Gustavo Padovan
2012-05-24 22:59 ` [PATCH 05/12] Bluetooth: Use chan->state instead of sk->sk_state Gustavo Padovan
2012-05-24 22:59 ` [PATCH 06/12] Bluetooth: Move check for backlog size to l2cap_sock.c Gustavo Padovan
2012-05-25  7:17   ` Andrei Emeltchenko
2012-05-24 22:59 ` [PATCH 07/12] Bluetooth: Create DEFER_SETUP flag in conf_state Gustavo Padovan
2012-05-24 22:59 ` [PATCH 08/12] Bluetooth: Add chan->ops->defer() Gustavo Padovan
2012-05-25  7:29   ` Andrei Emeltchenko
2012-05-24 22:59 ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Gustavo Padovan
2012-05-24 23:05   ` [PATCH 10/12] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Gustavo Padovan
2012-05-24 23:05     ` [PATCH 11/12] Bluetooth: Remove parent socket usage from l2cap_core.c Gustavo Padovan
2012-05-24 23:05     ` [PATCH 12/12] Bluetooth: Used void * as parameter in alloc_skb() Gustavo Padovan
2012-05-25  7:32   ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Andrei Emeltchenko

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=1337900389-30915-3-git-send-email-gustavo@padovan.org \
    --to=gustavo@padovan.org \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=linux-bluetooth@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