diff options
author | Yijing Wang <wangyijing@huawei.com> | 2013-04-12 01:44:27 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-04-16 12:27:14 -0400 |
commit | ad41dd9dd0c8ca1876f30b62c5c79625ffe83174 (patch) | |
tree | 232365e7fc61dad6aac4a16f956b307330619e27 /drivers/pci | |
parent | 3b63aaa70e1ccc4b66d60acc78da09700706a703 (diff) |
PCI: acpiphp: Use normal list to simplify implementation
Use normal list for struct acpiphp_slot to simplify implementation.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Yinghai Lu <yinghai@kernel.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/hotplug/acpiphp.h | 4 | ||||
-rw-r--r-- | drivers/pci/hotplug/acpiphp_glue.c | 23 |
2 files changed, 12 insertions, 15 deletions
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index abd48d309ad0..4ff716b6a6b3 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h | |||
@@ -73,8 +73,8 @@ static inline const char *slot_name(struct slot *slot) | |||
73 | */ | 73 | */ |
74 | struct acpiphp_bridge { | 74 | struct acpiphp_bridge { |
75 | struct list_head list; | 75 | struct list_head list; |
76 | struct list_head slots; | ||
76 | acpi_handle handle; | 77 | acpi_handle handle; |
77 | struct acpiphp_slot *slots; | ||
78 | 78 | ||
79 | /* Ejectable PCI-to-PCI bridge (PCI bridge and PCI function) */ | 79 | /* Ejectable PCI-to-PCI bridge (PCI bridge and PCI function) */ |
80 | struct acpiphp_func *func; | 80 | struct acpiphp_func *func; |
@@ -97,7 +97,7 @@ struct acpiphp_bridge { | |||
97 | * PCI slot information for each *physical* PCI slot | 97 | * PCI slot information for each *physical* PCI slot |
98 | */ | 98 | */ |
99 | struct acpiphp_slot { | 99 | struct acpiphp_slot { |
100 | struct acpiphp_slot *next; | 100 | struct list_head node; |
101 | struct acpiphp_bridge *bridge; /* parent */ | 101 | struct acpiphp_bridge *bridge; /* parent */ |
102 | struct list_head funcs; /* one slot may have different | 102 | struct list_head funcs; /* one slot may have different |
103 | objects (i.e. for each function) */ | 103 | objects (i.e. for each function) */ |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 20db4d6564a8..453a749d9595 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -154,7 +154,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
154 | acpi_handle tmp; | 154 | acpi_handle tmp; |
155 | acpi_status status = AE_OK; | 155 | acpi_status status = AE_OK; |
156 | unsigned long long adr, sun; | 156 | unsigned long long adr, sun; |
157 | int device, function, retval; | 157 | int device, function, retval, found = 0; |
158 | struct pci_bus *pbus = bridge->pci_bus; | 158 | struct pci_bus *pbus = bridge->pci_bus; |
159 | struct pci_dev *pdev; | 159 | struct pci_dev *pdev; |
160 | u32 val; | 160 | u32 val; |
@@ -208,14 +208,15 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
208 | } | 208 | } |
209 | 209 | ||
210 | /* search for objects that share the same slot */ | 210 | /* search for objects that share the same slot */ |
211 | for (slot = bridge->slots; slot; slot = slot->next) | 211 | list_for_each_entry(slot, &bridge->slots, node) |
212 | if (slot->device == device) { | 212 | if (slot->device == device) { |
213 | if (slot->sun != sun) | 213 | if (slot->sun != sun) |
214 | warn("sibling found, but _SUN doesn't match!\n"); | 214 | warn("sibling found, but _SUN doesn't match!\n"); |
215 | found = 1; | ||
215 | break; | 216 | break; |
216 | } | 217 | } |
217 | 218 | ||
218 | if (!slot) { | 219 | if (!found) { |
219 | slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); | 220 | slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); |
220 | if (!slot) { | 221 | if (!slot) { |
221 | kfree(newfunc); | 222 | kfree(newfunc); |
@@ -228,9 +229,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
228 | INIT_LIST_HEAD(&slot->funcs); | 229 | INIT_LIST_HEAD(&slot->funcs); |
229 | mutex_init(&slot->crit_sect); | 230 | mutex_init(&slot->crit_sect); |
230 | 231 | ||
231 | slot->next = bridge->slots; | 232 | list_add_tail(&slot->node, &bridge->slots); |
232 | bridge->slots = slot; | ||
233 | |||
234 | bridge->nr_slots++; | 233 | bridge->nr_slots++; |
235 | 234 | ||
236 | dbg("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n", | 235 | dbg("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n", |
@@ -289,7 +288,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
289 | 288 | ||
290 | err_exit: | 289 | err_exit: |
291 | bridge->nr_slots--; | 290 | bridge->nr_slots--; |
292 | bridge->slots = slot->next; | 291 | list_del(&slot->node); |
293 | kfree(slot); | 292 | kfree(slot); |
294 | kfree(newfunc); | 293 | kfree(newfunc); |
295 | 294 | ||
@@ -353,7 +352,7 @@ static struct acpiphp_func *acpiphp_bridge_handle_to_function(acpi_handle handle | |||
353 | struct acpiphp_func *func; | 352 | struct acpiphp_func *func; |
354 | 353 | ||
355 | list_for_each_entry(bridge, &bridge_list, list) { | 354 | list_for_each_entry(bridge, &bridge_list, list) { |
356 | for (slot = bridge->slots; slot; slot = slot->next) { | 355 | list_for_each_entry(slot, &bridge->slots, node) { |
357 | list_for_each_entry(func, &slot->funcs, sibling) { | 356 | list_for_each_entry(func, &slot->funcs, sibling) { |
358 | if (func->handle == handle) | 357 | if (func->handle == handle) |
359 | return func; | 358 | return func; |
@@ -400,9 +399,7 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) | |||
400 | err("failed to install interrupt notify handler\n"); | 399 | err("failed to install interrupt notify handler\n"); |
401 | } | 400 | } |
402 | 401 | ||
403 | slot = bridge->slots; | 402 | list_for_each_entry_safe(slot, next, &bridge->slots, node) { |
404 | while (slot) { | ||
405 | next = slot->next; | ||
406 | list_for_each_entry_safe(func, tmp, &slot->funcs, sibling) { | 403 | list_for_each_entry_safe(func, tmp, &slot->funcs, sibling) { |
407 | if (is_dock_device(func->handle)) { | 404 | if (is_dock_device(func->handle)) { |
408 | unregister_hotplug_dock_device(func->handle); | 405 | unregister_hotplug_dock_device(func->handle); |
@@ -421,7 +418,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) | |||
421 | acpiphp_unregister_hotplug_slot(slot); | 418 | acpiphp_unregister_hotplug_slot(slot); |
422 | list_del(&slot->funcs); | 419 | list_del(&slot->funcs); |
423 | kfree(slot); | 420 | kfree(slot); |
424 | slot = next; | ||
425 | } | 421 | } |
426 | 422 | ||
427 | put_device(&bridge->pci_bus->dev); | 423 | put_device(&bridge->pci_bus->dev); |
@@ -820,7 +816,7 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge) | |||
820 | 816 | ||
821 | enabled = disabled = 0; | 817 | enabled = disabled = 0; |
822 | 818 | ||
823 | for (slot = bridge->slots; slot; slot = slot->next) { | 819 | list_for_each_entry(slot, &bridge->slots, node) { |
824 | unsigned int status = get_slot_status(slot); | 820 | unsigned int status = get_slot_status(slot); |
825 | if (slot->flags & SLOT_ENABLED) { | 821 | if (slot->flags & SLOT_ENABLED) { |
826 | if (status == ACPI_STA_ALL) | 822 | if (status == ACPI_STA_ALL) |
@@ -1098,6 +1094,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle) | |||
1098 | return; | 1094 | return; |
1099 | } | 1095 | } |
1100 | 1096 | ||
1097 | INIT_LIST_HEAD(&bridge->slots); | ||
1101 | bridge->handle = handle; | 1098 | bridge->handle = handle; |
1102 | bridge->pci_dev = pci_dev_get(bus->self); | 1099 | bridge->pci_dev = pci_dev_get(bus->self); |
1103 | bridge->pci_bus = bus; | 1100 | bridge->pci_bus = bus; |