public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Ionut Nicu <ionut.nicu@mindbit.ro>
To: "Sapiens, Rene" <rene.sapiens@ti.com>
Cc: Ionut Nicu <ionut.nicu@gmail.com>,
	Greg Kroah-Hartman <greg@kroah.com>,
	Omar Ramirez Luna <omar.ramirez@ti.com>,
	Fernando Guzman Lugo <x0095840@ti.com>,
	Felipe Contreras <felipe.contreras@gmail.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-omap <linux-omap@vger.kernel.org>
Subject: Re: [PATCH v2 06/12] staging: tidspbridge: convert core to list_head
Date: Sat, 06 Nov 2010 19:21:23 +0200	[thread overview]
Message-ID: <1289064083.9931.43.camel@atlantis.mindbit.ro> (raw)
In-Reply-To: <AANLkTim+W3dn1j6SnVS6gc=aeZ0pH+VjSn+YiSJLangz@mail.gmail.com>

Hi Rene,

On Fri, 2010-11-05 at 15:07 -0600, Sapiens, Rene wrote:
> Hi Ionut,
> 
> On Fri, Nov 5, 2010 at 9:13 AM, Ionut Nicu <ionut.nicu@gmail.com> wrote:
> > Convert the core module of the tidspbridge driver
> > to use struct list_head instead of struct lst_list.
> >
> 
> <snip>
> 
> >        if (!status) {
> >                /* Get a free chirp: */
> > -               chnl_packet_obj =
> > -                   (struct chnl_irp *)lst_get_head(pchnl->free_packets_list);
> > -               if (chnl_packet_obj == NULL)
> > +               if (!list_empty(&pchnl->free_packets_list)) {
> > +                       chnl_packet_obj = list_first_entry(
> > +                                       &pchnl->free_packets_list,
> > +                                       struct chnl_irp, link);
> > +                       list_del(&chnl_packet_obj->link);
> > +               } else
> >                        status = -EIO;
> 
> What do you think if we close the braces, since the first conditional
> has more than one statement?
> 

Can you clarify? I don't think I understand which brace we need to close
here.

> <snip>
> 
> > @@ -286,18 +286,16 @@ int bridge_chnl_cancel_io(struct chnl_object *chnl_obj)
> >                }
> >        }
> >        /* Move all IOR's to IOC queue: */
> > -       while (!LST_IS_EMPTY(pchnl->pio_requests)) {
> > -               chnl_packet_obj =
> > -                   (struct chnl_irp *)lst_get_head(pchnl->pio_requests);
> > -               if (chnl_packet_obj) {
> > -                       chnl_packet_obj->byte_size = 0;
> > -                       chnl_packet_obj->status |= CHNL_IOCSTATCANCEL;
> > -                       lst_put_tail(pchnl->pio_completions,
> > -                                    (struct list_head *)chnl_packet_obj);
> > -                       pchnl->cio_cs++;
> > -                       pchnl->cio_reqs--;
> > -                       DBC_ASSERT(pchnl->cio_reqs >= 0);
> > -               }
> > +       while (!list_empty(&pchnl->pio_requests)) {
> > +               chnl_packet_obj = list_first_entry(&pchnl->pio_requests,
> > +                               struct chnl_irp, link);
> > +               list_del(&chnl_packet_obj->link);
> > +               chnl_packet_obj->byte_size = 0;
> > +               chnl_packet_obj->status |= CHNL_IOCSTATCANCEL;
> > +               list_add_tail(&chnl_packet_obj->link, &pchnl->pio_completions);
> > +               pchnl->cio_cs++;
> > +               pchnl->cio_reqs--;
> > +               DBC_ASSERT(pchnl->cio_reqs >= 0);
> 
> Why don't we use list_for_each_entry_safe() instead?
> 

Agreed, it will look better.


> >        }
> >  func_cont:
> >        spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
> 
> <snip>
> 
> > @@ -818,9 +804,19 @@ int bridge_chnl_open(struct chnl_object **chnl,
> >        /* Protect queues from io_dpc: */
> >        pchnl->dw_state = CHNL_STATECANCEL;
> >        /* Allocate initial IOR and IOC queues: */
> > -       pchnl->free_packets_list = create_chirp_list(pattrs->uio_reqs);
> > -       pchnl->pio_requests = create_chirp_list(0);
> > -       pchnl->pio_completions = create_chirp_list(0);
> > +       status = create_chirp_list(&pchnl->free_packets_list,
> > +                       pattrs->uio_reqs);
> > +       if (status)
> > +               goto func_end;
> > +
> > +       status = create_chirp_list(&pchnl->pio_requests, 0);
> > +       if (status)
> > +               goto func_end;
> > +
> > +       status = create_chirp_list(&pchnl->pio_completions, 0);
> > +       if (status)
> > +               goto func_end;
> > +
> 
> With these goto you are not freeing the memory allocated for pchnl, please free
> it at func_end.
> 

Thanks for catching this. Freeing it at func_end is not a very good
idea, because it's also freed above. 

What do you think if I replace the last two calls for
create_chirp_list() with just INIT_LIST_HEAD()? This way we'll have only
one error check where we'll also kfree(pchnl) and we'll have 2 less
un-necessary function calls / error checks.

Regards,
Ionut.


  reply	other threads:[~2010-11-06 17:21 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-05 15:13 [PATCH v2 00/12] staging: tidspbridge: various cleanups Ionut Nicu
2010-11-05 15:13 ` [PATCH v2 01/12] staging: tidspbridge: remove gs memory allocator Ionut Nicu
2010-11-05 15:13 ` [PATCH v2 02/12] staging: tidspbridge: remove utildefs Ionut Nicu
2010-11-05 15:13 ` [PATCH v2 03/12] staging: tidspbridge: switch to linux bitmap API Ionut Nicu
2010-11-05 15:13 ` [PATCH v2 04/12] staging: tidspbridge: remove gb bitmap implementation Ionut Nicu
2010-11-05 15:13 ` [PATCH v2 05/12] staging: tidspbridge: rmgr/node.c code cleanup Ionut Nicu
2010-11-05 15:13 ` [PATCH v2 06/12] staging: tidspbridge: convert core to list_head Ionut Nicu
2010-11-05 21:07   ` Sapiens, Rene
2010-11-06 17:21     ` Ionut Nicu [this message]
2010-11-08 19:15       ` Sapiens, Rene
2010-11-05 22:12   ` Sapiens, Rene
2010-11-06 17:31     ` Ionut Nicu
2010-11-08 19:16       ` Sapiens, Rene
2010-11-05 15:13 ` [PATCH v2 07/12] staging: tidspbridge: convert pmgr " Ionut Nicu
2010-11-05 22:41   ` Sapiens, Rene
2010-11-07 13:39     ` Ionut Nicu
2010-11-08 19:17       ` Sapiens, Rene
2010-11-05 15:13 ` [PATCH v2 08/12] staging: tidspbridge: convert rmgr " Ionut Nicu
2010-11-06  0:07   ` Sapiens, Rene
2010-11-06 18:18     ` Ionut Nicu
2010-11-06 18:26       ` Greg KH
2010-11-07 12:11         ` Ionut Nicu
2010-11-07 14:24           ` Nishanth Menon
2010-11-07 15:59           ` Greg KH
2010-11-08 19:18       ` Sapiens, Rene
2010-11-05 15:13 ` [PATCH v2 09/12] staging: tidspbridge: remove custom linked list Ionut Nicu
2010-11-05 15:13 ` [PATCH v2 10/12] staging: tidspbridge: core code cleanup Ionut Nicu
2010-11-05 15:13 ` [PATCH v2 11/12] staging: tidspbridge: pmgr " Ionut Nicu
2010-11-05 15:13 ` [PATCH v2 12/12] staging: tidspbridge: rmgr " Ionut Nicu
2010-11-05 15:43 ` [PATCH v2 00/12] staging: tidspbridge: various cleanups Greg KH
2010-11-05 16:02   ` Ionut Nicu

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=1289064083.9931.43.camel@atlantis.mindbit.ro \
    --to=ionut.nicu@mindbit.ro \
    --cc=andy.shevchenko@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=greg@kroah.com \
    --cc=ionut.nicu@gmail.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=omar.ramirez@ti.com \
    --cc=rene.sapiens@ti.com \
    --cc=x0095840@ti.com \
    /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