Re: [PATCH 3/3] Bluetooth: Remove l2cap_sk_list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

> Hi Gustavo,
> 
> On Wed, Apr 27, 2011 at 5:49 PM, Gustavo F. Padovan
> <padovan@xxxxxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux