All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Padovan <gustavo@padovan.org>
To: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
Cc: linux-bluetooth@vger.kernel.org, mathewm@codeaurora.org
Subject: Re: [RFC] Bluetooth: Adds unlink to chan ops
Date: Wed, 23 May 2012 17:31:20 -0300	[thread overview]
Message-ID: <20120523203120.GA21117@joana> (raw)
In-Reply-To: <1337760349-301-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-05-23 11:05:49 +0300]:

> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> This helps to separate socket and socketless code. Now socket related
> operations moved to l2cap_sock in unlink callback for channels with sk.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> Reported-by: Mat Martineau <mathewm@codeaurora.org>
> ---
>  include/net/bluetooth/l2cap.h |    1 +
>  net/bluetooth/l2cap_core.c    |   20 ++------------------
>  net/bluetooth/l2cap_sock.c    |   25 +++++++++++++++++++++++++
>  3 files changed, 28 insertions(+), 18 deletions(-)
> 
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index 69ef077..7ed13e7 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -532,6 +532,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			(*unlink) (struct l2cap_chan *chan, int err);
>  };
>  
>  struct l2cap_conn {
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index c64da38..d2b16b5 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -520,9 +520,7 @@ void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
>  
>  static void l2cap_chan_del(struct l2cap_chan *chan, int err)
>  {
> -	struct sock *sk = chan->sk;
>  	struct l2cap_conn *conn = chan->conn;
> -	struct sock *parent;
>  
>  	__clear_chan_timer(chan);
>  
> @@ -541,22 +539,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
>  	if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP)
>  		goto clean;
>  
> -	lock_sock(sk);
> -
> -	__l2cap_state_change(chan, BT_CLOSED);
> -	sock_set_flag(sk, SOCK_ZAPPED);
> -
> -	if (err)
> -		__l2cap_chan_set_err(chan, err);
> -
> -	parent = bt_sk(sk)->parent;
> -	if (parent) {
> -		bt_accept_unlink(sk);
> -		parent->sk_data_ready(parent, 0);
> -	} else
> -		sk->sk_state_change(sk);
> -
> -	release_sock(sk);
> +	if (chan->ops->unlink)
> +		chan->ops->unlink(chan, err);
>  
>  	if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
>  		return;
> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> index 3bb1611..d6f481b 100644
> --- a/net/bluetooth/l2cap_sock.c
> +++ b/net/bluetooth/l2cap_sock.c
> @@ -955,6 +955,30 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
>  	return skb;
>  }
>  
> +static void l2cap_sock_unlink_cb(struct l2cap_chan *chan, int err)
> +{
> +	struct sock *sk = chan->sk;
> +	struct sock *parent = bt_sk(sk)->parent;
> +
> +	lock_sock(sk);
> +
> +	chan->state = BT_CLOSED;
> +	sk->sk_state = BT_CLOSED;
> +	sock_set_flag(sk, SOCK_ZAPPED);

I think we can improve this code and call it everytime we need to set
SOCK_ZAPPED. We just need a bit more of logic here.

	Gustavo

  parent reply	other threads:[~2012-05-23 20:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-23  8:05 [RFC] Bluetooth: Adds unlink to chan ops Andrei Emeltchenko
2012-05-23 11:03 ` Ulisses Furquim
2012-05-23 20:31 ` Gustavo Padovan [this message]
2012-05-23 22:03   ` Ulisses Furquim
2012-05-24  8:18     ` Andrei Emeltchenko
2012-05-24  8:33       ` Gustavo Padovan

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=20120523203120.GA21117@joana \
    --to=gustavo@padovan.org \
    --cc=Andrei.Emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mathewm@codeaurora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.