Linux ACPI
 help / color / mirror / Atom feed
* [PATCH] ACPI: remove unnecessary INIT_LIST_HEAD
@ 2012-11-27  9:03 Andy Shevchenko
  2012-11-27  9:24 ` Westerberg, Mika
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2012-11-27  9:03 UTC (permalink / raw)
  To: Rafael J . Wysocki, Westerberg, Mika, linux-acpi; +Cc: Andy Shevchenko

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(-)

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI: remove unnecessary INIT_LIST_HEAD
  2012-11-27  9:03 [PATCH] ACPI: remove unnecessary INIT_LIST_HEAD Andy Shevchenko
@ 2012-11-27  9:24 ` Westerberg, Mika
  2012-11-27  9:49   ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Westerberg, Mika @ 2012-11-27  9:24 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Rafael J . Wysocki, linux-acpi

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI: remove unnecessary INIT_LIST_HEAD
  2012-11-27  9:24 ` Westerberg, Mika
@ 2012-11-27  9:49   ` Andy Shevchenko
  2012-11-27 10:05     ` Westerberg, Mika
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2012-11-27  9:49 UTC (permalink / raw)
  To: Westerberg, Mika; +Cc: Rafael J . Wysocki, linux-acpi

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

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI: remove unnecessary INIT_LIST_HEAD
  2012-11-27  9:49   ` Andy Shevchenko
@ 2012-11-27 10:05     ` Westerberg, Mika
  2012-11-27 19:10       ` Rafael J. Wysocki
  0 siblings, 1 reply; 5+ messages in thread
From: Westerberg, Mika @ 2012-11-27 10:05 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Rafael J . Wysocki, linux-acpi

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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI: remove unnecessary INIT_LIST_HEAD
  2012-11-27 10:05     ` Westerberg, Mika
@ 2012-11-27 19:10       ` Rafael J. Wysocki
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2012-11-27 19:10 UTC (permalink / raw)
  To: linux-acpi; +Cc: Westerberg, Mika, Andy Shevchenko, Rafael J . Wysocki

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


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-27 19:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-27  9:03 [PATCH] ACPI: remove unnecessary INIT_LIST_HEAD Andy Shevchenko
2012-11-27  9:24 ` Westerberg, Mika
2012-11-27  9:49   ` Andy Shevchenko
2012-11-27 10:05     ` Westerberg, Mika
2012-11-27 19:10       ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox