Skip to contentSkip to conversation

ACPI: remove unnecessary INIT_LIST_HEAD

PATCH Applied Andy Shevchenko 3 participants 5 messages Nov 27, 2012 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: remove unnecessary INIT_LIST_HEAD

There is no need to initialize the node before appending it to the list.

---
 drivers/acpi/resource.c |    1 -
 1 file changed, 1 deletion(-)
drivers/acpi/resource.c +0 -1
index 4107c00..a3868f6 100644
@@ -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++;
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 1 line · Andy Shevchenko

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?

Quoted 20 lines
---
 drivers/acpi/resource.c |    1 -
 1 file changed, 1 deletion(-)
drivers/acpi/resource.c +0 -1
index 4107c00..a3868f6 100644
@@ -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++;
Signature · 1 line
1.7.10.4
#2 lore raw
Quoted 5 lines · Mika
Quoted 1 line · Andy Shevchenko

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.

Quoted 20 lines
Quoted 20 lines
---
 drivers/acpi/resource.c |    1 -
 1 file changed, 1 deletion(-)
drivers/acpi/resource.c +0 -1
index 4107c00..a3868f6 100644
@@ -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++;
Signature · 1 line
1.7.10.4
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
Reviewed-by Mika Westerberg
#3 lore raw
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Mika
Quoted 1 line · Andy Shevchenko

There is no need to initialize the node before appending it to the list.

Quoted 8 lines
Quoted 2 lines

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.

#4 lore raw
Quoted 12 lines · Mika
Quoted 11 lines · Andy Shevchenko
Quoted 5 lines · Mika
Quoted 1 line · Andy Shevchenko

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.

Quoted 5 lines
Quoted 1 line

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

OK. Thanks for the explanation.

Applied.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.