aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/device_pm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/device_pm.c')
-rw-r--r--drivers/acpi/device_pm.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 67075f800e34..bea6896be122 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -1041,6 +1041,40 @@ static struct dev_pm_domain acpi_general_pm_domain = {
1041}; 1041};
1042 1042
1043/** 1043/**
1044 * acpi_dev_pm_detach - Remove ACPI power management from the device.
1045 * @dev: Device to take care of.
1046 * @power_off: Whether or not to try to remove power from the device.
1047 *
1048 * Remove the device from the general ACPI PM domain and remove its wakeup
1049 * notifier. If @power_off is set, additionally remove power from the device if
1050 * possible.
1051 *
1052 * Callers must ensure proper synchronization of this function with power
1053 * management callbacks.
1054 */
1055static void acpi_dev_pm_detach(struct device *dev, bool power_off)
1056{
1057 struct acpi_device *adev = ACPI_COMPANION(dev);
1058
1059 if (adev && dev->pm_domain == &acpi_general_pm_domain) {
1060 dev->pm_domain = NULL;
1061 acpi_remove_pm_notifier(adev);
1062 if (power_off) {
1063 /*
1064 * If the device's PM QoS resume latency limit or flags
1065 * have been exposed to user space, they have to be
1066 * hidden at this point, so that they don't affect the
1067 * choice of the low-power state to put the device into.
1068 */
1069 dev_pm_qos_hide_latency_limit(dev);
1070 dev_pm_qos_hide_flags(dev);
1071 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
1072 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
1073 }
1074 }
1075}
1076
1077/**
1044 * acpi_dev_pm_attach - Prepare device for ACPI power management. 1078 * acpi_dev_pm_attach - Prepare device for ACPI power management.
1045 * @dev: Device to prepare. 1079 * @dev: Device to prepare.
1046 * @power_on: Whether or not to power on the device. 1080 * @power_on: Whether or not to power on the device.
@@ -1072,42 +1106,9 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
1072 acpi_dev_pm_full_power(adev); 1106 acpi_dev_pm_full_power(adev);
1073 acpi_device_wakeup(adev, ACPI_STATE_S0, false); 1107 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
1074 } 1108 }
1109
1110 dev->pm_domain->detach = acpi_dev_pm_detach;
1075 return 0; 1111 return 0;
1076} 1112}
1077EXPORT_SYMBOL_GPL(acpi_dev_pm_attach); 1113EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
1078
1079/**
1080 * acpi_dev_pm_detach - Remove ACPI power management from the device.
1081 * @dev: Device to take care of.
1082 * @power_off: Whether or not to try to remove power from the device.
1083 *
1084 * Remove the device from the general ACPI PM domain and remove its wakeup
1085 * notifier. If @power_off is set, additionally remove power from the device if
1086 * possible.
1087 *
1088 * Callers must ensure proper synchronization of this function with power
1089 * management callbacks.
1090 */
1091void acpi_dev_pm_detach(struct device *dev, bool power_off)
1092{
1093 struct acpi_device *adev = ACPI_COMPANION(dev);
1094
1095 if (adev && dev->pm_domain == &acpi_general_pm_domain) {
1096 dev->pm_domain = NULL;
1097 acpi_remove_pm_notifier(adev);
1098 if (power_off) {
1099 /*
1100 * If the device's PM QoS resume latency limit or flags
1101 * have been exposed to user space, they have to be
1102 * hidden at this point, so that they don't affect the
1103 * choice of the low-power state to put the device into.
1104 */
1105 dev_pm_qos_hide_latency_limit(dev);
1106 dev_pm_qos_hide_flags(dev);
1107 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
1108 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
1109 }
1110 }
1111}
1112EXPORT_SYMBOL_GPL(acpi_dev_pm_detach);
1113#endif /* CONFIG_PM */ 1114#endif /* CONFIG_PM */