aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/power.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-17 08:11:06 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-17 08:11:06 -0500
commit993cbe595dda731471a07f4f65575fadedc570dc (patch)
tree2fb3877c89bf031acdbae666fe4530d88eb5945f /drivers/acpi/power.c
parent0b224527323669c66e0a37ae05b04034bfcdce14 (diff)
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.c44
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,
469 */ 469 */
470int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) 470int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
471{ 471{
472 int i, err = 0; 472 int err = 0;
473 473
474 if (!dev || !dev->wakeup.flags.valid) 474 if (!dev || !dev->wakeup.flags.valid)
475 return -EINVAL; 475 return -EINVAL;
@@ -479,24 +479,17 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
479 if (dev->wakeup.prepare_count++) 479 if (dev->wakeup.prepare_count++)
480 goto out; 480 goto out;
481 481
482 /* Open power resource */ 482 err = acpi_power_on_list(&dev->wakeup.resources);
483 for (i = 0; i < dev->wakeup.resources.count; i++) { 483 if (err) {
484 int ret = acpi_power_on(dev->wakeup.resources.handles[i]); 484 dev_err(&dev->dev, "Cannot turn wakeup power resources on\n");
485 if (ret) { 485 dev->wakeup.flags.valid = 0;
486 printk(KERN_ERR PREFIX "Transition power state\n"); 486 } else {
487 dev->wakeup.flags.valid = 0; 487 /*
488 err = -ENODEV; 488 * Passing 3 as the third argument below means the device may be
489 goto err_out; 489 * put into arbitrary power state afterward.
490 } 490 */
491 err = acpi_device_sleep_wake(dev, 1, sleep_state, 3);
491 } 492 }
492
493 /*
494 * Passing 3 as the third argument below means the device may be placed
495 * in arbitrary power state afterwards.
496 */
497 err = acpi_device_sleep_wake(dev, 1, sleep_state, 3);
498
499 err_out:
500 if (err) 493 if (err)
501 dev->wakeup.prepare_count = 0; 494 dev->wakeup.prepare_count = 0;
502 495
@@ -513,7 +506,7 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
513 */ 506 */
514int acpi_disable_wakeup_device_power(struct acpi_device *dev) 507int acpi_disable_wakeup_device_power(struct acpi_device *dev)
515{ 508{
516 int i, err = 0; 509 int err = 0;
517 510
518 if (!dev || !dev->wakeup.flags.valid) 511 if (!dev || !dev->wakeup.flags.valid)
519 return -EINVAL; 512 return -EINVAL;
@@ -534,15 +527,10 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
534 if (err) 527 if (err)
535 goto out; 528 goto out;
536 529
537 /* Close power resource */ 530 err = acpi_power_off_list(&dev->wakeup.resources);
538 for (i = 0; i < dev->wakeup.resources.count; i++) { 531 if (err) {
539 int ret = acpi_power_off(dev->wakeup.resources.handles[i]); 532 dev_err(&dev->dev, "Cannot turn wakeup power resources off\n");
540 if (ret) { 533 dev->wakeup.flags.valid = 0;
541 printk(KERN_ERR PREFIX "Transition power state\n");
542 dev->wakeup.flags.valid = 0;
543 err = -ENODEV;
544 goto out;
545 }
546 } 534 }
547 535
548 out: 536 out: