summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/power.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-17 08:11:07 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-17 08:11:07 -0500
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 242feca231eb..4b93c97aff9f 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)
97 return container_of(device, struct acpi_power_resource, device); 97 return container_of(device, struct acpi_power_resource, device);
98} 98}
99 99
100void acpi_power_resources_list_add(acpi_handle handle, struct list_head *list) 100static void acpi_power_resources_list_add(acpi_handle handle,
101 struct list_head *list)
101{ 102{
102 struct acpi_power_resource *resource = acpi_power_get_context(handle); 103 struct acpi_power_resource *resource = acpi_power_get_context(handle);
103 struct acpi_power_resource_entry *entry; 104 struct acpi_power_resource_entry *entry;
@@ -132,6 +133,35 @@ void acpi_power_resources_list_free(struct list_head *list)
132 } 133 }
133} 134}
134 135
136acpi_status acpi_extract_power_resources(union acpi_object *package,
137 unsigned int start,
138 struct list_head *list)
139{
140 acpi_status status = AE_OK;
141 unsigned int i;
142
143 for (i = start; i < package->package.count; i++) {
144 union acpi_object *element = &package->package.elements[i];
145 acpi_handle rhandle;
146
147 if (element->type != ACPI_TYPE_LOCAL_REFERENCE) {
148 status = AE_BAD_DATA;
149 break;
150 }
151 rhandle = element->reference.handle;
152 if (!rhandle) {
153 status = AE_NULL_ENTRY;
154 break;
155 }
156 acpi_add_power_resource(rhandle);
157 acpi_power_resources_list_add(rhandle, list);
158 }
159 if (ACPI_FAILURE(status))
160 acpi_power_resources_list_free(list);
161
162 return status;
163}
164
135static int acpi_power_get_state(acpi_handle handle, int *state) 165static int acpi_power_get_state(acpi_handle handle, int *state)
136{ 166{
137 acpi_status status = AE_OK; 167 acpi_status status = AE_OK;