aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlexander Chiang <achiang@hp.com>2009-06-10 15:55:14 -0400
committerLen Brown <len.brown@intel.com>2009-06-17 23:22:15 -0400
commit275582031f9b3597a1b973f3ff617adfe639faa2 (patch)
tree7f4e2c43709758108042e5dcf9b89d756e5bf8e5 /drivers
parentce597bb42aa84bc73db80509b7c37e7fbc0b75c4 (diff)
ACPI: Introduce acpi_is_root_bridge()
Returns whether an ACPI CA node is a PCI root bridge or not. This API is generically useful, and shouldn't just be a hotplug function. The implementation becomes much simpler as well. Signed-off-by: Alex Chiang <achiang@hp.com> Acked-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/pci_root.c24
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c40
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c2
3 files changed, 27 insertions, 39 deletions
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index ca8dba3b40b9..888cb9f5c5fb 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -142,6 +142,30 @@ acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus)
142 142
143EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle); 143EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle);
144 144
145/**
146 * acpi_is_root_bridge - determine whether an ACPI CA node is a PCI root bridge
147 * @handle - the ACPI CA node in question.
148 *
149 * Note: we could make this API take a struct acpi_device * instead, but
150 * for now, it's more convenient to operate on an acpi_handle.
151 */
152int acpi_is_root_bridge(acpi_handle handle)
153{
154 int ret;
155 struct acpi_device *device;
156
157 ret = acpi_bus_get_device(handle, &device);
158 if (ret)
159 return 0;
160
161 ret = acpi_match_device_ids(device, root_device_ids);
162 if (ret)
163 return 0;
164 else
165 return 1;
166}
167EXPORT_SYMBOL_GPL(acpi_is_root_bridge);
168
145static acpi_status 169static acpi_status
146get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) 170get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
147{ 171{
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index fbc63d5e459f..eb159587d0bf 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -354,7 +354,7 @@ acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus,
354 status = acpi_run_hpp(handle, hpp); 354 status = acpi_run_hpp(handle, hpp);
355 if (ACPI_SUCCESS(status)) 355 if (ACPI_SUCCESS(status))
356 break; 356 break;
357 if (acpi_root_bridge(handle)) 357 if (acpi_is_root_bridge(handle))
358 break; 358 break;
359 status = acpi_get_parent(handle, &phandle); 359 status = acpi_get_parent(handle, &phandle);
360 if (ACPI_FAILURE(status)) 360 if (ACPI_FAILURE(status))
@@ -428,7 +428,7 @@ int acpi_get_hp_hw_control_from_firmware(struct pci_dev *pdev, u32 flags)
428 status = acpi_run_oshp(handle); 428 status = acpi_run_oshp(handle);
429 if (ACPI_SUCCESS(status)) 429 if (ACPI_SUCCESS(status))
430 goto got_one; 430 goto got_one;
431 if (acpi_root_bridge(handle)) 431 if (acpi_is_root_bridge(handle))
432 break; 432 break;
433 chandle = handle; 433 chandle = handle;
434 status = acpi_get_parent(chandle, &handle); 434 status = acpi_get_parent(chandle, &handle);
@@ -449,42 +449,6 @@ got_one:
449} 449}
450EXPORT_SYMBOL(acpi_get_hp_hw_control_from_firmware); 450EXPORT_SYMBOL(acpi_get_hp_hw_control_from_firmware);
451 451
452/* acpi_root_bridge - check to see if this acpi object is a root bridge
453 *
454 * @handle - the acpi object in question.
455 */
456int acpi_root_bridge(acpi_handle handle)
457{
458 acpi_status status;
459 struct acpi_device_info *info;
460 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
461 int i;
462
463 status = acpi_get_object_info(handle, &buffer);
464 if (ACPI_SUCCESS(status)) {
465 info = buffer.pointer;
466 if ((info->valid & ACPI_VALID_HID) &&
467 !strcmp(PCI_ROOT_HID_STRING,
468 info->hardware_id.value)) {
469 kfree(buffer.pointer);
470 return 1;
471 }
472 if (info->valid & ACPI_VALID_CID) {
473 for (i=0; i < info->compatibility_id.count; i++) {
474 if (!strcmp(PCI_ROOT_HID_STRING,
475 info->compatibility_id.id[i].value)) {
476 kfree(buffer.pointer);
477 return 1;
478 }
479 }
480 }
481 kfree(buffer.pointer);
482 }
483 return 0;
484}
485EXPORT_SYMBOL_GPL(acpi_root_bridge);
486
487
488static int is_ejectable(acpi_handle handle) 452static int is_ejectable(acpi_handle handle)
489{ 453{
490 acpi_status status; 454 acpi_status status;
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 3a6064bce561..fc6636e3300b 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -1631,7 +1631,7 @@ find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
1631{ 1631{
1632 int *count = (int *)context; 1632 int *count = (int *)context;
1633 1633
1634 if (acpi_root_bridge(handle)) { 1634 if (acpi_is_root_bridge(handle)) {
1635 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 1635 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
1636 handle_hotplug_event_bridge, NULL); 1636 handle_hotplug_event_bridge, NULL);
1637 (*count)++; 1637 (*count)++;