aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhao Yakui <yakui.zhao@intel.com>2008-08-11 02:55:05 -0400
committerLen Brown <len.brown@intel.com>2008-10-22 17:58:00 -0400
commita51e145f379ae48003129610922595893e8efde0 (patch)
treeb3294f55421628124709d846ebdc2efbbbc7ca11
parent08237974af22a97da59869979ef1a515524d5cc3 (diff)
ACPI: Get the device power state in the course of scanning device
Get the device power state in the course of scanning device if the device power flag is power_managable. i.e. The device has the _PSx/_PRx object. At the same time before the drivers/acpi/power module is loaded, there is no relation between acpi_power_resource and acpi device. So the first parameter of acpi_power_get_state is changed to acpi_handle. http://bugzilla.kernel.org/show_bug.cgi?id=8049 http://bugzilla.kernel.org/show_bug.cgi?id=11000 Signed-off-by: Zhao Yakui <yakui.zhao@intel.com> Signed-off-by: Li Shaohua <shaohua.li@intel.com> Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/power.c30
-rw-r--r--drivers/acpi/scan.c1
2 files changed, 17 insertions, 14 deletions
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 4ab21cb1c8c7..e7bab75075a9 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -128,16 +128,16 @@ acpi_power_get_context(acpi_handle handle,
128 return 0; 128 return 0;
129} 129}
130 130
131static int acpi_power_get_state(struct acpi_power_resource *resource, int *state) 131static int acpi_power_get_state(acpi_handle handle, int *state)
132{ 132{
133 acpi_status status = AE_OK; 133 acpi_status status = AE_OK;
134 unsigned long sta = 0; 134 unsigned long sta = 0;
135 135
136 136
137 if (!resource || !state) 137 if (!handle || !state)
138 return -EINVAL; 138 return -EINVAL;
139 139
140 status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta); 140 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
141 if (ACPI_FAILURE(status)) 141 if (ACPI_FAILURE(status))
142 return -ENODEV; 142 return -ENODEV;
143 143
@@ -145,7 +145,7 @@ static int acpi_power_get_state(struct acpi_power_resource *resource, int *state
145 ACPI_POWER_RESOURCE_STATE_OFF; 145 ACPI_POWER_RESOURCE_STATE_OFF;
146 146
147 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", 147 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
148 resource->name, state ? "on" : "off")); 148 acpi_ut_get_node_name(handle), state ? "on" : "off"));
149 149
150 return 0; 150 return 0;
151} 151}
@@ -153,7 +153,6 @@ static int acpi_power_get_state(struct acpi_power_resource *resource, int *state
153static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) 153static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
154{ 154{
155 int result = 0, state1; 155 int result = 0, state1;
156 struct acpi_power_resource *resource = NULL;
157 u32 i = 0; 156 u32 i = 0;
158 157
159 158
@@ -161,12 +160,15 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
161 return -EINVAL; 160 return -EINVAL;
162 161
163 /* The state of the list is 'on' IFF all resources are 'on'. */ 162 /* The state of the list is 'on' IFF all resources are 'on'. */
163 /* */
164 164
165 for (i = 0; i < list->count; i++) { 165 for (i = 0; i < list->count; i++) {
166 result = acpi_power_get_context(list->handles[i], &resource); 166 /*
167 if (result) 167 * The state of the power resource can be obtained by
168 return result; 168 * using the ACPI handle. In such case it is unnecessary to
169 result = acpi_power_get_state(resource, &state1); 169 * get the Power resource first and then get its state again.
170 */
171 result = acpi_power_get_state(list->handles[i], &state1);
170 if (result) 172 if (result)
171 return result; 173 return result;
172 174
@@ -226,7 +228,7 @@ static int acpi_power_on(acpi_handle handle, struct acpi_device *dev)
226 if (ACPI_FAILURE(status)) 228 if (ACPI_FAILURE(status))
227 return -ENODEV; 229 return -ENODEV;
228 230
229 result = acpi_power_get_state(resource, &state); 231 result = acpi_power_get_state(resource->device->handle, &state);
230 if (result) 232 if (result)
231 return result; 233 return result;
232 if (state != ACPI_POWER_RESOURCE_STATE_ON) 234 if (state != ACPI_POWER_RESOURCE_STATE_ON)
@@ -277,7 +279,7 @@ static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev)
277 if (ACPI_FAILURE(status)) 279 if (ACPI_FAILURE(status))
278 return -ENODEV; 280 return -ENODEV;
279 281
280 result = acpi_power_get_state(resource, &state); 282 result = acpi_power_get_state(handle, &state);
281 if (result) 283 if (result)
282 return result; 284 return result;
283 if (state != ACPI_POWER_RESOURCE_STATE_OFF) 285 if (state != ACPI_POWER_RESOURCE_STATE_OFF)
@@ -555,7 +557,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
555 if (!resource) 557 if (!resource)
556 goto end; 558 goto end;
557 559
558 result = acpi_power_get_state(resource, &state); 560 result = acpi_power_get_state(resource->device->handle, &state);
559 if (result) 561 if (result)
560 goto end; 562 goto end;
561 563
@@ -668,7 +670,7 @@ static int acpi_power_add(struct acpi_device *device)
668 resource->system_level = acpi_object.power_resource.system_level; 670 resource->system_level = acpi_object.power_resource.system_level;
669 resource->order = acpi_object.power_resource.resource_order; 671 resource->order = acpi_object.power_resource.resource_order;
670 672
671 result = acpi_power_get_state(resource, &state); 673 result = acpi_power_get_state(device->handle, &state);
672 if (result) 674 if (result)
673 goto end; 675 goto end;
674 676
@@ -735,7 +737,7 @@ static int acpi_power_resume(struct acpi_device *device)
735 737
736 resource = (struct acpi_power_resource *)acpi_driver_data(device); 738 resource = (struct acpi_power_resource *)acpi_driver_data(device);
737 739
738 result = acpi_power_get_state(resource, &state); 740 result = acpi_power_get_state(device->handle, &state);
739 if (result) 741 if (result)
740 return result; 742 return result;
741 743
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index f6f52c1a2aba..308ddb1c207c 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -807,6 +807,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
807 /* TBD: System wake support and resource requirements. */ 807 /* TBD: System wake support and resource requirements. */
808 808
809 device->power.state = ACPI_STATE_UNKNOWN; 809 device->power.state = ACPI_STATE_UNKNOWN;
810 acpi_bus_get_power(device->handle, &(device->power.state));
810 811
811 return 0; 812 return 0;
812} 813}