aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sleep.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-01 20:40:53 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-14 18:15:18 -0500
commita6ae7594b1b157e0e7976ed105a7be27d69a5361 (patch)
treead9d2fdca3d7a20335d29498101917eb8fc8782b /drivers/acpi/sleep.c
parent078eb12648c2f8bba48921f60ec2cec3e1bbc051 (diff)
ACPI / PM: Move device PM functions related to sleep states
Introduce helper function returning the target sleep state of the system and use it to move the remaining device power management functions from sleep.c to device_pm.c. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/sleep.c')
-rw-r--r--drivers/acpi/sleep.c63
1 files changed, 6 insertions, 57 deletions
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 77c517f6f6d0..13a285dffaca 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -80,6 +80,12 @@ static int acpi_sleep_prepare(u32 acpi_state)
80 80
81#ifdef CONFIG_ACPI_SLEEP 81#ifdef CONFIG_ACPI_SLEEP
82static u32 acpi_target_sleep_state = ACPI_STATE_S0; 82static u32 acpi_target_sleep_state = ACPI_STATE_S0;
83
84u32 acpi_target_system_state(void)
85{
86 return acpi_target_sleep_state;
87}
88
83static bool pwr_btn_event_pending; 89static bool pwr_btn_event_pending;
84 90
85/* 91/*
@@ -680,63 +686,6 @@ int acpi_suspend(u32 acpi_state)
680 return -EINVAL; 686 return -EINVAL;
681} 687}
682 688
683#ifdef CONFIG_PM
684/**
685 * acpi_pm_device_sleep_state - Get preferred power state of ACPI device.
686 * @dev: Device whose preferred target power state to return.
687 * @d_min_p: Location to store the upper limit of the allowed states range.
688 * @d_max_in: Deepest low-power state to take into consideration.
689 * Return value: Preferred power state of the device on success, -ENODEV
690 * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure
691 *
692 * The caller must ensure that @dev is valid before using this function.
693 */
694int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
695{
696 acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
697 struct acpi_device *adev;
698
699 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
700 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
701 return -ENODEV;
702 }
703
704 return acpi_device_power_state(dev, adev, acpi_target_sleep_state,
705 d_max_in, d_min_p);
706}
707EXPORT_SYMBOL(acpi_pm_device_sleep_state);
708#endif /* CONFIG_PM */
709
710#ifdef CONFIG_PM_SLEEP
711/**
712 * acpi_pm_device_sleep_wake - Enable or disable device to wake up the system.
713 * @dev: Device to enable/desible to wake up the system from sleep states.
714 * @enable: Whether to enable or disable @dev to wake up the system.
715 */
716int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
717{
718 acpi_handle handle;
719 struct acpi_device *adev;
720 int error;
721
722 if (!device_can_wakeup(dev))
723 return -EINVAL;
724
725 handle = DEVICE_ACPI_HANDLE(dev);
726 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
727 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
728 return -ENODEV;
729 }
730
731 error = __acpi_device_sleep_wake(adev, acpi_target_sleep_state, enable);
732 if (!error)
733 dev_info(dev, "System wakeup %s by ACPI\n",
734 enable ? "enabled" : "disabled");
735
736 return error;
737}
738#endif /* CONFIG_PM_SLEEP */
739
740static void acpi_power_off_prepare(void) 689static void acpi_power_off_prepare(void)
741{ 690{
742 /* Prepare to power off the system */ 691 /* Prepare to power off the system */