Commit ad41dd9d authored by Yijing Wang's avatar Yijing Wang Committed by Bjorn Helgaas

PCI: acpiphp: Use normal list to simplify implementation

Use normal list for struct acpiphp_slot to simplify implementation.
Signed-off-by: default avatarYijing Wang <wangyijing@huawei.com>
Signed-off-by: default avatarJiang Liu <jiang.liu@huawei.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarYinghai Lu <yinghai@kernel.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Toshi Kani <toshi.kani@hp.com>
parent 3b63aaa7
...@@ -73,8 +73,8 @@ static inline const char *slot_name(struct slot *slot) ...@@ -73,8 +73,8 @@ static inline const char *slot_name(struct slot *slot)
*/ */
struct acpiphp_bridge { struct acpiphp_bridge {
struct list_head list; struct list_head list;
struct list_head slots;
acpi_handle handle; acpi_handle handle;
struct acpiphp_slot *slots;
/* Ejectable PCI-to-PCI bridge (PCI bridge and PCI function) */ /* Ejectable PCI-to-PCI bridge (PCI bridge and PCI function) */
struct acpiphp_func *func; struct acpiphp_func *func;
...@@ -97,7 +97,7 @@ struct acpiphp_bridge { ...@@ -97,7 +97,7 @@ struct acpiphp_bridge {
* PCI slot information for each *physical* PCI slot * PCI slot information for each *physical* PCI slot
*/ */
struct acpiphp_slot { struct acpiphp_slot {
struct acpiphp_slot *next; struct list_head node;
struct acpiphp_bridge *bridge; /* parent */ struct acpiphp_bridge *bridge; /* parent */
struct list_head funcs; /* one slot may have different struct list_head funcs; /* one slot may have different
objects (i.e. for each function) */ objects (i.e. for each function) */
......
...@@ -154,7 +154,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -154,7 +154,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
acpi_handle tmp; acpi_handle tmp;
acpi_status status = AE_OK; acpi_status status = AE_OK;
unsigned long long adr, sun; unsigned long long adr, sun;
int device, function, retval; int device, function, retval, found = 0;
struct pci_bus *pbus = bridge->pci_bus; struct pci_bus *pbus = bridge->pci_bus;
struct pci_dev *pdev; struct pci_dev *pdev;
u32 val; u32 val;
...@@ -208,14 +208,15 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -208,14 +208,15 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
} }
/* search for objects that share the same slot */ /* search for objects that share the same slot */
for (slot = bridge->slots; slot; slot = slot->next) list_for_each_entry(slot, &bridge->slots, node)
if (slot->device == device) { if (slot->device == device) {
if (slot->sun != sun) if (slot->sun != sun)
warn("sibling found, but _SUN doesn't match!\n"); warn("sibling found, but _SUN doesn't match!\n");
found = 1;
break; break;
} }
if (!slot) { if (!found) {
slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
if (!slot) { if (!slot) {
kfree(newfunc); kfree(newfunc);
...@@ -228,9 +229,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -228,9 +229,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
INIT_LIST_HEAD(&slot->funcs); INIT_LIST_HEAD(&slot->funcs);
mutex_init(&slot->crit_sect); mutex_init(&slot->crit_sect);
slot->next = bridge->slots; list_add_tail(&slot->node, &bridge->slots);
bridge->slots = slot;
bridge->nr_slots++; bridge->nr_slots++;
dbg("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n", 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,7 +288,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
err_exit: err_exit:
bridge->nr_slots--; bridge->nr_slots--;
bridge->slots = slot->next; list_del(&slot->node);
kfree(slot); kfree(slot);
kfree(newfunc); kfree(newfunc);
...@@ -353,7 +352,7 @@ static struct acpiphp_func *acpiphp_bridge_handle_to_function(acpi_handle handle ...@@ -353,7 +352,7 @@ static struct acpiphp_func *acpiphp_bridge_handle_to_function(acpi_handle handle
struct acpiphp_func *func; struct acpiphp_func *func;
list_for_each_entry(bridge, &bridge_list, list) { list_for_each_entry(bridge, &bridge_list, list) {
for (slot = bridge->slots; slot; slot = slot->next) { list_for_each_entry(slot, &bridge->slots, node) {
list_for_each_entry(func, &slot->funcs, sibling) { list_for_each_entry(func, &slot->funcs, sibling) {
if (func->handle == handle) if (func->handle == handle)
return func; return func;
...@@ -400,9 +399,7 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) ...@@ -400,9 +399,7 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
err("failed to install interrupt notify handler\n"); err("failed to install interrupt notify handler\n");
} }
slot = bridge->slots; list_for_each_entry_safe(slot, next, &bridge->slots, node) {
while (slot) {
next = slot->next;
list_for_each_entry_safe(func, tmp, &slot->funcs, sibling) { list_for_each_entry_safe(func, tmp, &slot->funcs, sibling) {
if (is_dock_device(func->handle)) { if (is_dock_device(func->handle)) {
unregister_hotplug_dock_device(func->handle); unregister_hotplug_dock_device(func->handle);
...@@ -421,7 +418,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) ...@@ -421,7 +418,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
acpiphp_unregister_hotplug_slot(slot); acpiphp_unregister_hotplug_slot(slot);
list_del(&slot->funcs); list_del(&slot->funcs);
kfree(slot); kfree(slot);
slot = next;
} }
put_device(&bridge->pci_bus->dev); put_device(&bridge->pci_bus->dev);
...@@ -820,7 +816,7 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge) ...@@ -820,7 +816,7 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge)
enabled = disabled = 0; enabled = disabled = 0;
for (slot = bridge->slots; slot; slot = slot->next) { list_for_each_entry(slot, &bridge->slots, node) {
unsigned int status = get_slot_status(slot); unsigned int status = get_slot_status(slot);
if (slot->flags & SLOT_ENABLED) { if (slot->flags & SLOT_ENABLED) {
if (status == ACPI_STA_ALL) if (status == ACPI_STA_ALL)
...@@ -1098,6 +1094,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle) ...@@ -1098,6 +1094,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle)
return; return;
} }
INIT_LIST_HEAD(&bridge->slots);
bridge->handle = handle; bridge->handle = handle;
bridge->pci_dev = pci_dev_get(bus->self); bridge->pci_dev = pci_dev_get(bus->self);
bridge->pci_bus = bus; bridge->pci_bus = bus;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment