aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-11-28 17:58:08 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-12-06 19:05:48 -0500
commit5ce79d201358d36f13d13b01d8614bd8e646036c (patch)
treef3e41f23b317e892287cb233c86b942e9e513786
parentd9fef0c4d2e08c3888add77f1dc54fb12afb3928 (diff)
PCI / ACPI: Use acpi_find_child_device() for child devices lookup
It is much more efficient to use acpi_find_child_device() for child devices lookup in acpi_pci_find_device() and pass ACPI_COMPANION(dev->parent) to it directly instead of obtaining ACPI_HANDLE() of ACPI_COMPANION(dev->parent) and passing it to acpi_find_child() which has to run acpi_bus_get_device() to obtain ACPI_COMPANION(dev->parent) from that again. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Aaron Lu <aaron.lu@intel.com>
-rw-r--r--drivers/acpi/glue.c3
-rw-r--r--drivers/pci/pci-acpi.c16
2 files changed, 13 insertions, 6 deletions
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index ea77512ad70c..9d200d5029ca 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -106,6 +106,9 @@ struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
106 struct acpi_device *adev, *ret = NULL; 106 struct acpi_device *adev, *ret = NULL;
107 int ret_score = 0; 107 int ret_score = 0;
108 108
109 if (!parent)
110 return NULL;
111
109 list_for_each_entry(adev, &parent->children, node) { 112 list_for_each_entry(adev, &parent->children, node) {
110 unsigned long long addr; 113 unsigned long long addr;
111 acpi_status status; 114 acpi_status status;
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 43e317991326..adbf34003995 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -306,7 +306,8 @@ void acpi_pci_remove_bus(struct pci_bus *bus)
306static int acpi_pci_find_device(struct device *dev, acpi_handle *handle) 306static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
307{ 307{
308 struct pci_dev *pci_dev = to_pci_dev(dev); 308 struct pci_dev *pci_dev = to_pci_dev(dev);
309 bool is_bridge; 309 struct acpi_device *adev;
310 bool check_children;
310 u64 addr; 311 u64 addr;
311 312
312 /* 313 /*
@@ -314,14 +315,17 @@ static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
314 * is set only after acpi_pci_find_device() has been called for the 315 * is set only after acpi_pci_find_device() has been called for the
315 * given device. 316 * given device.
316 */ 317 */
317 is_bridge = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE 318 check_children = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE
318 || pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS; 319 || pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
319 /* Please ref to ACPI spec for the syntax of _ADR */ 320 /* Please ref to ACPI spec for the syntax of _ADR */
320 addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); 321 addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
321 *handle = acpi_find_child(ACPI_HANDLE(dev->parent), addr, is_bridge); 322 adev = acpi_find_child_device(ACPI_COMPANION(dev->parent), addr,
322 if (!*handle) 323 check_children);
323 return -ENODEV; 324 if (adev) {
324 return 0; 325 *handle = adev->handle;
326 return 0;
327 }
328 return -ENODEV;
325} 329}
326 330
327static void pci_acpi_setup(struct device *dev) 331static void pci_acpi_setup(struct device *dev)