Skip to contentSkip to conversation

acpiphp: fix use of list_for_each macro

PATCH In review Akinobu Mita 2 participants 2 messages Oct 28, 2006 – Oct 30, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpiphp: fix use of list_for_each macro

This patch fixes invalid usage of list_for_each()

list_for_each (node, &bridge_list) {
	bridge = (struct acpiphp_bridge *)node;
	...
}

This code works while the member of list node is located at the head of struct acpiphp_bridge.

Cc Greg Kroah-Hartman <[email protected]>
Cc Kristen Carlson Accardi <[email protected]>
 drivers/pci/hotplug/acpiphp_glue.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +2 -6
Index: work-fault-inject/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
@@ -1693,14 +1693,10 @@ void __exit acpiphp_glue_exit(void)
  */
 int __init acpiphp_get_num_slots(void)
 {
-	struct list_head *node;
 	struct acpiphp_bridge *bridge;
-	int num_slots;
-
-	num_slots = 0;
+	int num_slots = 0;
 
-	list_for_each (node, &bridge_list) {
-		bridge = (struct acpiphp_bridge *)node;
+	list_for_each_entry (bridge, &bridge_list, list) {
 		dbg("Bus %04x:%02x has %d slot%s\n",
 				pci_domain_nr(bridge->pci_bus),
 				bridge->pci_bus->number, bridge->nr_slots,
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Sun, 29 Oct 2006 03:39:43 +0900 Akinobu Mita <[email protected]> wrote:

This patch fixes invalid usage of list_for_each()

list_for_each (node, &bridge_list) {
	bridge = (struct acpiphp_bridge *)node;
	...
}
Quoted 6 lines

This code works while the member of list node is located at the head of struct acpiphp_bridge.

Cc Greg Kroah-Hartman <[email protected]>
Cc Kristen Carlson Accardi <[email protected]>
Quoted 25 lines
 drivers/pci/hotplug/acpiphp_glue.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Index: work-fault-inject/drivers/pci/hotplug/acpiphp_glue.c
===================================================================

drivers/pci/hotplug/acpiphp_glue.c +2 -6
@@ -1693,14 +1693,10 @@ void __exit acpiphp_glue_exit(void)
  */
 int __init acpiphp_get_num_slots(void)
 {
-	struct list_head *node;
 	struct acpiphp_bridge *bridge;
-	int num_slots;
-
-	num_slots = 0;
+	int num_slots = 0;
 
-	list_for_each (node, &bridge_list) {
-		bridge = (struct acpiphp_bridge *)node;
+	list_for_each_entry (bridge, &bridge_list, list) {
 		dbg("Bus %04x:%02x has %d slot%s\n",
 				pci_domain_nr(bridge->pci_bus),
 				bridge->pci_bus->number, bridge->nr_slots,