diff mbox

ACPI: remove unnecessary INIT_LIST_HEAD

Message ID 1354007025-8334-1-git-send-email-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Andy Shevchenko Nov. 27, 2012, 9:03 a.m. UTC
There is no need to initialize the node before appending it to the list.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/resource.c |    1 -
 1 file changed, 1 deletion(-)

Comments

Mika Westerberg Nov. 27, 2012, 9:24 a.m. UTC | #1
On Tue, Nov 27, 2012 at 11:03:45AM +0200, Andy Shevchenko wrote:
> There is no need to initialize the node before appending it to the list.

I might be missing something but why do we then have macros like:
list_del_init() etc?

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/acpi/resource.c |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
> index 4107c00..a3868f6 100644
> --- a/drivers/acpi/resource.c
> +++ b/drivers/acpi/resource.c
> @@ -426,7 +426,6 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,
>  		c->error = -ENOMEM;
>  		return AE_NO_MEMORY;
>  	}
> -	INIT_LIST_HEAD(&rentry->node);
>  	rentry->res = *r;
>  	list_add_tail(&rentry->node, c->list);
>  	c->count++;
> -- 
> 1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andy Shevchenko Nov. 27, 2012, 9:49 a.m. UTC | #2
On Tue, 2012-11-27 at 11:24 +0200, Westerberg, Mika wrote: 
> On Tue, Nov 27, 2012 at 11:03:45AM +0200, Andy Shevchenko wrote:
> > There is no need to initialize the node before appending it to the list.
> 
> I might be missing something but why do we then have macros like:
> list_del_init() etc?

list_del_init(&list->node) allows to reuse &list->node as a new list.
I guess the often use case of that when you extract the leaf node from
the list of lists and create a new list based on it.

In our case we just add a node to the existed list.


> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  drivers/acpi/resource.c |    1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
> > index 4107c00..a3868f6 100644
> > --- a/drivers/acpi/resource.c
> > +++ b/drivers/acpi/resource.c
> > @@ -426,7 +426,6 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,
> >  		c->error = -ENOMEM;
> >  		return AE_NO_MEMORY;
> >  	}
> > -	INIT_LIST_HEAD(&rentry->node);
> >  	rentry->res = *r;
> >  	list_add_tail(&rentry->node, c->list);
> >  	c->count++;
> > -- 
> > 1.7.10.4
Mika Westerberg Nov. 27, 2012, 10:05 a.m. UTC | #3
On Tue, Nov 27, 2012 at 11:49:21AM +0200, Andy Shevchenko wrote:
> On Tue, 2012-11-27 at 11:24 +0200, Westerberg, Mika wrote: 
> > On Tue, Nov 27, 2012 at 11:03:45AM +0200, Andy Shevchenko wrote:
> > > There is no need to initialize the node before appending it to the list.
> > 
> > I might be missing something but why do we then have macros like:
> > list_del_init() etc?
> 
> list_del_init(&list->node) allows to reuse &list->node as a new list.
> I guess the often use case of that when you extract the leaf node from
> the list of lists and create a new list based on it.
> 
> In our case we just add a node to the existed list.

OK. Thanks for the explanation.

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael Wysocki Nov. 27, 2012, 7:10 p.m. UTC | #4
On Tuesday, November 27, 2012 12:05:55 PM Westerberg, Mika wrote:
> On Tue, Nov 27, 2012 at 11:49:21AM +0200, Andy Shevchenko wrote:
> > On Tue, 2012-11-27 at 11:24 +0200, Westerberg, Mika wrote: 
> > > On Tue, Nov 27, 2012 at 11:03:45AM +0200, Andy Shevchenko wrote:
> > > > There is no need to initialize the node before appending it to the list.
> > > 
> > > I might be missing something but why do we then have macros like:
> > > list_del_init() etc?
> > 
> > list_del_init(&list->node) allows to reuse &list->node as a new list.
> > I guess the often use case of that when you extract the leaf node from
> > the list of lists and create a new list based on it.
> > 
> > In our case we just add a node to the existed list.
> 
> OK. Thanks for the explanation.
> 
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Applied.

Thanks,
Rafael
diff mbox

Patch

diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index 4107c00..a3868f6 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -426,7 +426,6 @@  static acpi_status acpi_dev_new_resource_entry(struct resource *r,
 		c->error = -ENOMEM;
 		return AE_NO_MEMORY;
 	}
-	INIT_LIST_HEAD(&rentry->node);
 	rentry->res = *r;
 	list_add_tail(&rentry->node, c->list);
 	c->count++;