aboutsummaryrefslogtreecommitdiff
path: root/drivers/acpi/power.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-17 14:11:07 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-17 14:11:07 +0100
commitef85bdbec444b42775a18580c6bfe1307a63ef0f (patch)
treeab98b0c41c1361438bff632a8a1cd739c63d8c53 /drivers/acpi/power.c
parent8bc5053bcdff09a6d1c6a61a79a9014884aa0a14 (diff)
ACPI / scan: Consolidate extraction of power resources lists
The lists of ACPI power resources are currently extracted in two different ways, one for wakeup power resources and one for power resources that device power states depend on. There is no reason why it should be done differently in those two cases, so introduce a common routine for extracting power resources lists from data returned by AML, acpi_extract_power_resources(), and make the namespace scanning code use it for both wakeup and device power states power resources. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/power.c')
-rw-r--r--drivers/acpi/power.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 242feca231e..4b93c97aff9 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -97,7 +97,8 @@ static struct acpi_power_resource *acpi_power_get_context(acpi_handle handle)
return container_of(device, struct acpi_power_resource, device);
}
-void acpi_power_resources_list_add(acpi_handle handle, struct list_head *list)
+static void acpi_power_resources_list_add(acpi_handle handle,
+ struct list_head *list)
{
struct acpi_power_resource *resource = acpi_power_get_context(handle);
struct acpi_power_resource_entry *entry;
@@ -132,6 +133,35 @@ void acpi_power_resources_list_free(struct list_head *list)
}
}
+acpi_status acpi_extract_power_resources(union acpi_object *package,
+ unsigned int start,
+ struct list_head *list)
+{
+ acpi_status status = AE_OK;
+ unsigned int i;
+
+ for (i = start; i < package->package.count; i++) {
+ union acpi_object *element = &package->package.elements[i];
+ acpi_handle rhandle;
+
+ if (element->type != ACPI_TYPE_LOCAL_REFERENCE) {
+ status = AE_BAD_DATA;
+ break;
+ }
+ rhandle = element->reference.handle;
+ if (!rhandle) {
+ status = AE_NULL_ENTRY;
+ break;
+ }
+ acpi_add_power_resource(rhandle);
+ acpi_power_resources_list_add(rhandle, list);
+ }
+ if (ACPI_FAILURE(status))
+ acpi_power_resources_list_free(list);
+
+ return status;
+}
+
static int acpi_power_get_state(acpi_handle handle, int *state)
{
acpi_status status = AE_OK;