提交 c1aec834 编写于 作者: B Bjorn Helgaas 提交者: Len Brown

ACPI: pci_root: simplify list traversals

Using list_for_each_entry() makes traversing the root list easier.
Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
Reviewed-by: NAlex Chiang <achiang@hp.com>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 caf420c6
...@@ -82,7 +82,7 @@ static DEFINE_MUTEX(osc_lock); ...@@ -82,7 +82,7 @@ static DEFINE_MUTEX(osc_lock);
int acpi_pci_register_driver(struct acpi_pci_driver *driver) int acpi_pci_register_driver(struct acpi_pci_driver *driver)
{ {
int n = 0; int n = 0;
struct list_head *entry; struct acpi_pci_root *root;
struct acpi_pci_driver **pptr = &sub_driver; struct acpi_pci_driver **pptr = &sub_driver;
while (*pptr) while (*pptr)
...@@ -92,9 +92,7 @@ int acpi_pci_register_driver(struct acpi_pci_driver *driver) ...@@ -92,9 +92,7 @@ int acpi_pci_register_driver(struct acpi_pci_driver *driver)
if (!driver->add) if (!driver->add)
return 0; return 0;
list_for_each(entry, &acpi_pci_roots) { list_for_each_entry(root, &acpi_pci_roots, node) {
struct acpi_pci_root *root;
root = list_entry(entry, struct acpi_pci_root, node);
driver->add(root->device->handle); driver->add(root->device->handle);
n++; n++;
} }
...@@ -106,7 +104,7 @@ EXPORT_SYMBOL(acpi_pci_register_driver); ...@@ -106,7 +104,7 @@ EXPORT_SYMBOL(acpi_pci_register_driver);
void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) void acpi_pci_unregister_driver(struct acpi_pci_driver *driver)
{ {
struct list_head *entry; struct acpi_pci_root *root;
struct acpi_pci_driver **pptr = &sub_driver; struct acpi_pci_driver **pptr = &sub_driver;
while (*pptr) { while (*pptr) {
...@@ -120,23 +118,19 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) ...@@ -120,23 +118,19 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver)
if (!driver->remove) if (!driver->remove)
return; return;
list_for_each(entry, &acpi_pci_roots) { list_for_each_entry(root, &acpi_pci_roots, node)
struct acpi_pci_root *root;
root = list_entry(entry, struct acpi_pci_root, node);
driver->remove(root->device->handle); driver->remove(root->device->handle);
}
} }
EXPORT_SYMBOL(acpi_pci_unregister_driver); EXPORT_SYMBOL(acpi_pci_unregister_driver);
acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus) acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus)
{ {
struct acpi_pci_root *tmp; struct acpi_pci_root *root;
list_for_each_entry(tmp, &acpi_pci_roots, node) { list_for_each_entry(root, &acpi_pci_roots, node)
if ((tmp->id.segment == (u16) seg) && (tmp->id.bus == (u16) bus)) if ((root->id.segment == (u16) seg) && (root->id.bus == (u16) bus))
return tmp->device->handle; return root->device->handle;
}
return NULL; return NULL;
} }
...@@ -301,6 +295,7 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags) ...@@ -301,6 +295,7 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags)
static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle) static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
{ {
struct acpi_pci_root *root; struct acpi_pci_root *root;
list_for_each_entry(root, &acpi_pci_roots, node) { list_for_each_entry(root, &acpi_pci_roots, node) {
if (root->device->handle == handle) if (root->device->handle == handle)
return root; return root;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册