aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-11-24 18:05:17 -0500
committerLen Brown <len.brown@intel.com>2011-01-12 04:48:43 -0500
commit32a00d274e877eab3ea7ab196b75c9be5170d25e (patch)
tree0b7a515e8b2328e8cf8b22794cdf81ab19838b5d /drivers/acpi
parent3c0eee3fe6a3a1c745379547c7e7c904aa64f6d5 (diff)
ACPI / PM: Prevent acpi_power_get_inferred_state() from making changes
acpi_power_get_inferred_state() should not update device->power.state behind the back of its caller, so make it return the state via a pointer instead. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/bus.c3
-rw-r--r--drivers/acpi/internal.h2
-rw-r--r--drivers/acpi/power.c12
3 files changed, 7 insertions, 10 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index d68bd61072bb..a9fe8e6bc40e 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -222,7 +222,8 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
222 * indirectly (via power resources). 222 * indirectly (via power resources).
223 */ 223 */
224 if (device->power.flags.power_resources) { 224 if (device->power.flags.power_resources) {
225 result = acpi_power_get_inferred_state(device); 225 result = acpi_power_get_inferred_state(device,
226 &device->power.state);
226 if (result) 227 if (result)
227 return result; 228 return result;
228 } else if (device->power.flags.explicit_get) { 229 } else if (device->power.flags.explicit_get) {
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index a212bfeddf8c..2cc01489dccf 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -41,7 +41,7 @@ static inline int acpi_debugfs_init(void) { return 0; }
41int acpi_power_init(void); 41int acpi_power_init(void);
42int acpi_device_sleep_wake(struct acpi_device *dev, 42int acpi_device_sleep_wake(struct acpi_device *dev,
43 int enable, int sleep_state, int dev_state); 43 int enable, int sleep_state, int dev_state);
44int acpi_power_get_inferred_state(struct acpi_device *device); 44int acpi_power_get_inferred_state(struct acpi_device *device, int *state);
45int acpi_power_transition(struct acpi_device *device, int state); 45int acpi_power_transition(struct acpi_device *device, int state);
46extern int acpi_power_nocheck; 46extern int acpi_power_nocheck;
47 47
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 4c9c2fb5d98f..9bd1b6044b55 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -423,19 +423,16 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
423 Device Power Management 423 Device Power Management
424 -------------------------------------------------------------------------- */ 424 -------------------------------------------------------------------------- */
425 425
426int acpi_power_get_inferred_state(struct acpi_device *device) 426int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
427{ 427{
428 int result = 0; 428 int result = 0;
429 struct acpi_handle_list *list = NULL; 429 struct acpi_handle_list *list = NULL;
430 int list_state = 0; 430 int list_state = 0;
431 int i = 0; 431 int i = 0;
432 432
433 433 if (!device || !state)
434 if (!device)
435 return -EINVAL; 434 return -EINVAL;
436 435
437 device->power.state = ACPI_STATE_UNKNOWN;
438
439 /* 436 /*
440 * We know a device's inferred power state when all the resources 437 * We know a device's inferred power state when all the resources
441 * required for a given D-state are 'on'. 438 * required for a given D-state are 'on'.
@@ -450,13 +447,12 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
450 return result; 447 return result;
451 448
452 if (list_state == ACPI_POWER_RESOURCE_STATE_ON) { 449 if (list_state == ACPI_POWER_RESOURCE_STATE_ON) {
453 device->power.state = i; 450 *state = i;
454 return 0; 451 return 0;
455 } 452 }
456 } 453 }
457 454
458 device->power.state = ACPI_STATE_D3; 455 *state = ACPI_STATE_D3;
459
460 return 0; 456 return 0;
461} 457}
462 458