diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-01-17 14:11:06 +0100 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-01-17 14:11:06 +0100 |
commit | 993cbe595dda731471a07f4f65575fadedc570dc (patch) | |
tree | 2fb3877c89bf031acdbae666fe4530d88eb5945f /drivers/acpi/power.c | |
parent | ACPI / PM: Take order attribute of power resources into account (diff) | |
download | linux-993cbe595dda731471a07f4f65575fadedc570dc.tar.xz linux-993cbe595dda731471a07f4f65575fadedc570dc.zip |
ACPI / PM: Take order attribute of wakeup power resources into account
ACPI power resources have an order attribute that should be taken
into account when turning them on and off, but it is not used now.
Modify the power resources management code to preserve the
spec-compliant ordering of wakeup 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.c | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 22a3d00d0359..242feca231eb 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -469,7 +469,7 @@ int acpi_device_sleep_wake(struct acpi_device *dev, */ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) { - int i, err = 0; + int err = 0; if (!dev || !dev->wakeup.flags.valid) return -EINVAL; @@ -479,24 +479,17 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) if (dev->wakeup.prepare_count++) goto out; - /* Open power resource */ - for (i = 0; i < dev->wakeup.resources.count; i++) { - int ret = acpi_power_on(dev->wakeup.resources.handles[i]); - if (ret) { - printk(KERN_ERR PREFIX "Transition power state\n"); - dev->wakeup.flags.valid = 0; - err = -ENODEV; - goto err_out; - } + err = acpi_power_on_list(&dev->wakeup.resources); + if (err) { + dev_err(&dev->dev, "Cannot turn wakeup power resources on\n"); + dev->wakeup.flags.valid = 0; + } else { + /* + * Passing 3 as the third argument below means the device may be + * put into arbitrary power state afterward. + */ + err = acpi_device_sleep_wake(dev, 1, sleep_state, 3); } - - /* - * Passing 3 as the third argument below means the device may be placed - * in arbitrary power state afterwards. - */ - err = acpi_device_sleep_wake(dev, 1, sleep_state, 3); - - err_out: if (err) dev->wakeup.prepare_count = 0; @@ -513,7 +506,7 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) */ int acpi_disable_wakeup_device_power(struct acpi_device *dev) { - int i, err = 0; + int err = 0; if (!dev || !dev->wakeup.flags.valid) return -EINVAL; @@ -534,15 +527,10 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev) if (err) goto out; - /* Close power resource */ - for (i = 0; i < dev->wakeup.resources.count; i++) { - int ret = acpi_power_off(dev->wakeup.resources.handles[i]); - if (ret) { - printk(KERN_ERR PREFIX "Transition power state\n"); - dev->wakeup.flags.valid = 0; - err = -ENODEV; - goto out; - } + err = acpi_power_off_list(&dev->wakeup.resources); + if (err) { + dev_err(&dev->dev, "Cannot turn wakeup power resources off\n"); + dev->wakeup.flags.valid = 0; } out: |