aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2017-10-03 03:11:08 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-10-11 09:35:50 -0400
commitc2ebf788f927dcca72beead19fab5f5aba79a098 (patch)
tree881d4e72a78ce0a0a50253be633265c3c4c73a15
parente4da817d2acbd05217adc0dc821bc8361e86ee30 (diff)
ACPI / PM: Split code validating need for runtime resume in ->prepare()
Move the code dealing with validation of whether runtime resuming the device is needed during system suspend. In this way it becomes more clear for what circumstances ACPI is prevented from trying the direct_complete path. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/device_pm.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index d17fac453a30..764b8dfa04aa 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -966,6 +966,27 @@ int acpi_dev_suspend_late(struct device *dev)
966} 966}
967EXPORT_SYMBOL_GPL(acpi_dev_suspend_late); 967EXPORT_SYMBOL_GPL(acpi_dev_suspend_late);
968 968
969static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev)
970{
971 u32 sys_target = acpi_target_system_state();
972 int ret, state;
973
974 if (device_may_wakeup(dev) != !!adev->wakeup.prepare_count)
975 return true;
976
977 if (sys_target == ACPI_STATE_S0)
978 return false;
979
980 if (adev->power.flags.dsw_present)
981 return true;
982
983 ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state);
984 if (ret)
985 return true;
986
987 return state != adev->power.state;
988}
989
969/** 990/**
970 * acpi_subsys_prepare - Prepare device for system transition to a sleep state. 991 * acpi_subsys_prepare - Prepare device for system transition to a sleep state.
971 * @dev: Device to prepare. 992 * @dev: Device to prepare.
@@ -973,26 +994,16 @@ EXPORT_SYMBOL_GPL(acpi_dev_suspend_late);
973int acpi_subsys_prepare(struct device *dev) 994int acpi_subsys_prepare(struct device *dev)
974{ 995{
975 struct acpi_device *adev = ACPI_COMPANION(dev); 996 struct acpi_device *adev = ACPI_COMPANION(dev);
976 u32 sys_target; 997 int ret;
977 int ret, state;
978 998
979 ret = pm_generic_prepare(dev); 999 ret = pm_generic_prepare(dev);
980 if (ret < 0) 1000 if (ret < 0)
981 return ret; 1001 return ret;
982 1002
983 if (!adev || !pm_runtime_suspended(dev) 1003 if (!adev || !pm_runtime_suspended(dev))
984 || device_may_wakeup(dev) != !!adev->wakeup.prepare_count)
985 return 0;
986
987 sys_target = acpi_target_system_state();
988 if (sys_target == ACPI_STATE_S0)
989 return 1;
990
991 if (adev->power.flags.dsw_present)
992 return 0; 1004 return 0;
993 1005
994 ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state); 1006 return !acpi_dev_needs_resume(dev, adev);
995 return !ret && state == adev->power.state;
996} 1007}
997EXPORT_SYMBOL_GPL(acpi_subsys_prepare); 1008EXPORT_SYMBOL_GPL(acpi_subsys_prepare);
998 1009