All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
To: Anderson Lizardo <anderson.lizardo@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 3/3] Bluetooth: Remove l2cap_sk_list
Date: Thu, 28 Apr 2011 02:13:02 -0300	[thread overview]
Message-ID: <20110428051302.GD2214@joana> (raw)
In-Reply-To: <BANLkTimYW2ZweS5GSnVQ6nn_WTs9+b0RcA@mail.gmail.com>

* Anderson Lizardo <anderson.lizardo@openbossa.org> [2011-04-27 19:19:35 -0400]:

> Hi Gustavo,
> 
> On Wed, Apr 27, 2011 at 5:49 PM, Gustavo F. Padovan
> <padovan@profusion.mobi> wrote:
> > @@ -883,33 +891,34 @@ static inline void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *ch
> >  /* Find socket with psm and source bdaddr.
> >  * Returns closest match.
> >  */
> > -static struct sock *l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src)
> > +static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, bdaddr_t *src)
> >  {
> > -       struct sock *sk = NULL, *sk1 = NULL;
> > -       struct hlist_node *node;
> > +       struct l2cap_chan *c, *c1 = NULL;
> >
> > -       read_lock(&l2cap_sk_list.lock);
> > +       read_lock(&chan_list_lock);
> >
> > -       sk_for_each(sk, node, &l2cap_sk_list.head) {
> > -               struct l2cap_chan *chan = l2cap_pi(sk)->chan;
> > +       list_for_each_entry(c, &chan_list, global_l) {
> > +               struct sock *sk = c->sk;
> >
> >                if (state && sk->sk_state != state)
> >                        continue;
> >
> > -               if (chan->psm == psm) {
> > +               if (c->psm == psm) {
> >                        /* Exact match. */
> > -                       if (!bacmp(&bt_sk(sk)->src, src))
> > -                               break;
> > +                       if (!bacmp(&bt_sk(sk)->src, src)) {
> > +                               read_unlock_bh(&chan_list_lock);
> > +                               return c;
> 
> What about this instead of the above:
> 
> c1 = c;
> break;
> 
> This avoids a duplicated read_unlock_bh() and keeps a single exit
> point for the function.

I still prefer my version. ;)

-- 
Gustavo F. Padovan
http://profusion.mobi

      reply	other threads:[~2011-04-28  5:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27 21:49 [PATCH 1/3] Bluetooth: Add l2cap_add_psm() and l2cap_add_scid() Gustavo F. Padovan
2011-04-27 21:49 ` [PATCH 2/3] Bluetooth: Handle psm == 0 case inside l2cap_add_psm() Gustavo F. Padovan
2011-04-27 21:49   ` [PATCH 3/3] Bluetooth: Remove l2cap_sk_list Gustavo F. Padovan
2011-04-27 22:06     ` Vinicius Costa Gomes
2011-04-27 23:19     ` Anderson Lizardo
2011-04-28  5:13       ` Gustavo F. Padovan [this message]

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=20110428051302.GD2214@joana \
    --to=padovan@profusion.mobi \
    --cc=anderson.lizardo@openbossa.org \
    --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 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.