提交 32a00d27 编写于 作者: R Rafael J. Wysocki 提交者: Len Brown

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: NRafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 3c0eee3f
......@@ -222,7 +222,8 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
* indirectly (via power resources).
*/
if (device->power.flags.power_resources) {
result = acpi_power_get_inferred_state(device);
result = acpi_power_get_inferred_state(device,
&device->power.state);
if (result)
return result;
} else if (device->power.flags.explicit_get) {
......
......@@ -41,7 +41,7 @@ static inline int acpi_debugfs_init(void) { return 0; }
int acpi_power_init(void);
int acpi_device_sleep_wake(struct acpi_device *dev,
int enable, int sleep_state, int dev_state);
int acpi_power_get_inferred_state(struct acpi_device *device);
int acpi_power_get_inferred_state(struct acpi_device *device, int *state);
int acpi_power_transition(struct acpi_device *device, int state);
extern int acpi_power_nocheck;
......
......@@ -423,19 +423,16 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
Device Power Management
-------------------------------------------------------------------------- */
int acpi_power_get_inferred_state(struct acpi_device *device)
int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
{
int result = 0;
struct acpi_handle_list *list = NULL;
int list_state = 0;
int i = 0;
if (!device)
if (!device || !state)
return -EINVAL;
device->power.state = ACPI_STATE_UNKNOWN;
/*
* We know a device's inferred power state when all the resources
* required for a given D-state are 'on'.
......@@ -450,13 +447,12 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
return result;
if (list_state == ACPI_POWER_RESOURCE_STATE_ON) {
device->power.state = i;
*state = i;
return 0;
}
}
device->power.state = ACPI_STATE_D3;
*state = ACPI_STATE_D3;
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册