diff options
author | Duncan Laurie <dlaurie@google.com> | 2018-05-07 14:28:53 -0700 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2018-05-18 12:22:40 +0000 |
commit | 8ccf59a94778fb54cc08368fb58a42b64d9489f6 (patch) | |
tree | d716576b67d4ccd78d37b3464762b86d36a196e8 | |
parent | 4021a5acb36e69c511db12aa24abd56063f4933a (diff) |
acpi: device: Walk up the tree to find identifier
Instead of just checking the immediate parent for an device name,
walk up the tree to check if any parent can identify the device.
This allows devices to be nested more than one level deep and
still have them identified in one place by the SOC.
Change-Id: I9938fc20a839db91ff25e91bba08baa7421e3cd4
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://review.coreboot.org/26172
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r-- | src/arch/x86/acpi_device.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/arch/x86/acpi_device.c b/src/arch/x86/acpi_device.c index c8d313e037..df2226d340 100644 --- a/src/arch/x86/acpi_device.c +++ b/src/arch/x86/acpi_device.c @@ -55,6 +55,9 @@ static void acpi_device_fill_len(void *ptr) /* Locate and return the ACPI name for this device */ const char *acpi_device_name(struct device *dev) { + struct device *pdev = dev; + const char *name; + if (!dev) return NULL; @@ -62,9 +65,16 @@ const char *acpi_device_name(struct device *dev) if (dev->ops->acpi_name) return dev->ops->acpi_name(dev); - /* Check parent device in case it has a global handler */ - if (dev->bus && dev->bus->dev->ops->acpi_name) - return dev->bus->dev->ops->acpi_name(dev); + /* Walk up the tree to find if any parent can identify this device */ + while (pdev->bus) { + if (pdev->path.type == DEVICE_PATH_ROOT) + break; + if (pdev->bus->dev->ops && pdev->bus->dev->ops->acpi_name) + name = pdev->bus->dev->ops->acpi_name(dev); + if (name) + return name; + pdev = pdev->bus->dev; + } return NULL; } |