From 38ac0f1b90dc9486cc039f1a4d8b0202813e5b67 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Fri, 11 May 2012 16:08:26 +0800 Subject: ACPI: Add _PLD support Add a simple helper function to allow drivers to obtain the physical device location data. Acked-by: Len Brown Signed-off-by: Matthew Garrett Signed-off-by: Lan Tianyu Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/utils.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index b002a471c5d4..adbbc1c80a26 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -382,3 +382,33 @@ acpi_evaluate_reference(acpi_handle handle, } EXPORT_SYMBOL(acpi_evaluate_reference); + +acpi_status +acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld *pld) +{ + acpi_status status; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *output; + + status = acpi_evaluate_object(handle, "_PLD", NULL, &buffer); + + if (ACPI_FAILURE(status)) + return status; + + output = buffer.pointer; + + if (!output || output->type != ACPI_TYPE_PACKAGE + || !output->package.count + || output->package.elements[0].type != ACPI_TYPE_BUFFER + || output->package.elements[0].buffer.length > sizeof(*pld)) { + status = AE_TYPE; + goto out; + } + + memcpy(pld, output->package.elements[0].buffer.pointer, + output->package.elements[0].buffer.length); +out: + kfree(buffer.pointer); + return status; +} +EXPORT_SYMBOL(acpi_get_physical_device_location); -- cgit v1.2.1