diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2009-06-18 16:47:02 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-06-20 00:01:53 -0400 |
commit | c1aec8341627dad5d63cc24aa6746dc077f5b706 (patch) | |
tree | f408c024c60a7d108e99f12a761b420a2bcc0c34 /drivers/acpi/pci_root.c | |
parent | caf420c68afe01acd7c458ce40b85b3db5330ff5 (diff) |
ACPI: pci_root: simplify list traversals
Using list_for_each_entry() makes traversing the root list easier.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Reviewed-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/pci_root.c')
-rw-r--r-- | drivers/acpi/pci_root.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 7984e00540fa..4fb747205418 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -82,7 +82,7 @@ static DEFINE_MUTEX(osc_lock); | |||
82 | int acpi_pci_register_driver(struct acpi_pci_driver *driver) | 82 | int acpi_pci_register_driver(struct acpi_pci_driver *driver) |
83 | { | 83 | { |
84 | int n = 0; | 84 | int n = 0; |
85 | struct list_head *entry; | 85 | struct acpi_pci_root *root; |
86 | 86 | ||
87 | struct acpi_pci_driver **pptr = &sub_driver; | 87 | struct acpi_pci_driver **pptr = &sub_driver; |
88 | while (*pptr) | 88 | while (*pptr) |
@@ -92,9 +92,7 @@ int acpi_pci_register_driver(struct acpi_pci_driver *driver) | |||
92 | if (!driver->add) | 92 | if (!driver->add) |
93 | return 0; | 93 | return 0; |
94 | 94 | ||
95 | list_for_each(entry, &acpi_pci_roots) { | 95 | list_for_each_entry(root, &acpi_pci_roots, node) { |
96 | struct acpi_pci_root *root; | ||
97 | root = list_entry(entry, struct acpi_pci_root, node); | ||
98 | driver->add(root->device->handle); | 96 | driver->add(root->device->handle); |
99 | n++; | 97 | n++; |
100 | } | 98 | } |
@@ -106,7 +104,7 @@ EXPORT_SYMBOL(acpi_pci_register_driver); | |||
106 | 104 | ||
107 | void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) | 105 | void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) |
108 | { | 106 | { |
109 | struct list_head *entry; | 107 | struct acpi_pci_root *root; |
110 | 108 | ||
111 | struct acpi_pci_driver **pptr = &sub_driver; | 109 | struct acpi_pci_driver **pptr = &sub_driver; |
112 | while (*pptr) { | 110 | while (*pptr) { |
@@ -120,23 +118,19 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) | |||
120 | if (!driver->remove) | 118 | if (!driver->remove) |
121 | return; | 119 | return; |
122 | 120 | ||
123 | list_for_each(entry, &acpi_pci_roots) { | 121 | list_for_each_entry(root, &acpi_pci_roots, node) |
124 | struct acpi_pci_root *root; | ||
125 | root = list_entry(entry, struct acpi_pci_root, node); | ||
126 | driver->remove(root->device->handle); | 122 | driver->remove(root->device->handle); |
127 | } | ||
128 | } | 123 | } |
129 | 124 | ||
130 | EXPORT_SYMBOL(acpi_pci_unregister_driver); | 125 | EXPORT_SYMBOL(acpi_pci_unregister_driver); |
131 | 126 | ||
132 | acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus) | 127 | acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus) |
133 | { | 128 | { |
134 | struct acpi_pci_root *tmp; | 129 | struct acpi_pci_root *root; |
135 | 130 | ||
136 | list_for_each_entry(tmp, &acpi_pci_roots, node) { | 131 | list_for_each_entry(root, &acpi_pci_roots, node) |
137 | if ((tmp->id.segment == (u16) seg) && (tmp->id.bus == (u16) bus)) | 132 | if ((root->id.segment == (u16) seg) && (root->id.bus == (u16) bus)) |
138 | return tmp->device->handle; | 133 | return root->device->handle; |
139 | } | ||
140 | return NULL; | 134 | return NULL; |
141 | } | 135 | } |
142 | 136 | ||
@@ -301,6 +295,7 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags) | |||
301 | static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle) | 295 | static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle) |
302 | { | 296 | { |
303 | struct acpi_pci_root *root; | 297 | struct acpi_pci_root *root; |
298 | |||
304 | list_for_each_entry(root, &acpi_pci_roots, node) { | 299 | list_for_each_entry(root, &acpi_pci_roots, node) { |
305 | if (root->device->handle == handle) | 300 | if (root->device->handle == handle) |
306 | return root; | 301 | return root; |