ACPI: Introduce new device wakeup flag 'prepared'
Introduce additional flag 'prepared' in struct acpi_device_wakeup_flags and use it to prevent devices from being enable/disabled do wake up the system multiple times in a row (this does not happen currently, but will be possible after some of the following patches). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
Родитель
77e766099e
Коммит
0af4b8c4fb
|
@ -363,11 +363,18 @@ int acpi_device_sleep_wake(struct acpi_device *dev,
|
||||||
*/
|
*/
|
||||||
int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
|
int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
|
||||||
{
|
{
|
||||||
int i;
|
int i, err;
|
||||||
|
|
||||||
if (!dev || !dev->wakeup.flags.valid)
|
if (!dev || !dev->wakeup.flags.valid)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do not execute the code below twice in a row without calling
|
||||||
|
* acpi_disable_wakeup_device_power() in between for the same device
|
||||||
|
*/
|
||||||
|
if (dev->wakeup.flags.prepared)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* Open power resource */
|
/* Open power resource */
|
||||||
for (i = 0; i < dev->wakeup.resources.count; i++) {
|
for (i = 0; i < dev->wakeup.resources.count; i++) {
|
||||||
int ret = acpi_power_on(dev->wakeup.resources.handles[i], dev);
|
int ret = acpi_power_on(dev->wakeup.resources.handles[i], dev);
|
||||||
|
@ -382,7 +389,11 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
|
||||||
* Passing 3 as the third argument below means the device may be placed
|
* Passing 3 as the third argument below means the device may be placed
|
||||||
* in arbitrary power state afterwards.
|
* in arbitrary power state afterwards.
|
||||||
*/
|
*/
|
||||||
return acpi_device_sleep_wake(dev, 1, sleep_state, 3);
|
err = acpi_device_sleep_wake(dev, 1, sleep_state, 3);
|
||||||
|
if (!err)
|
||||||
|
dev->wakeup.flags.prepared = 1;
|
||||||
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -398,6 +409,15 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
|
||||||
if (!dev || !dev->wakeup.flags.valid)
|
if (!dev || !dev->wakeup.flags.valid)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do not execute the code below twice in a row without calling
|
||||||
|
* acpi_enable_wakeup_device_power() in between for the same device
|
||||||
|
*/
|
||||||
|
if (!dev->wakeup.flags.prepared)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
dev->wakeup.flags.prepared = 0;
|
||||||
|
|
||||||
ret = acpi_device_sleep_wake(dev, 0, 0, 0);
|
ret = acpi_device_sleep_wake(dev, 0, 0, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -259,6 +259,7 @@ struct acpi_device_perf {
|
||||||
/* Wakeup Management */
|
/* Wakeup Management */
|
||||||
struct acpi_device_wakeup_flags {
|
struct acpi_device_wakeup_flags {
|
||||||
u8 valid:1; /* Can successfully enable wakeup? */
|
u8 valid:1; /* Can successfully enable wakeup? */
|
||||||
|
u8 prepared:1; /* Has the wake-up capability been enabled? */
|
||||||
u8 run_wake:1; /* Run-Wake GPE devices */
|
u8 run_wake:1; /* Run-Wake GPE devices */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче