diff options
Diffstat (limited to 'drivers/acpi/device_pm.c')
-rw-r--r-- | drivers/acpi/device_pm.c | 64 |
1 files changed, 5 insertions, 59 deletions
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 59d3202f6b36..d42b2fb5a7e9 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
@@ -118,9 +118,10 @@ int acpi_device_get_power(struct acpi_device *device, int *state) | |||
118 | /* | 118 | /* |
119 | * If we were unsure about the device parent's power state up to this | 119 | * If we were unsure about the device parent's power state up to this |
120 | * point, the fact that the device is in D0 implies that the parent has | 120 | * point, the fact that the device is in D0 implies that the parent has |
121 | * to be in D0 too. | 121 | * to be in D0 too, except if ignore_parent is set. |
122 | */ | 122 | */ |
123 | if (device->parent && device->parent->power.state == ACPI_STATE_UNKNOWN | 123 | if (!device->power.flags.ignore_parent && device->parent |
124 | && device->parent->power.state == ACPI_STATE_UNKNOWN | ||
124 | && result == ACPI_STATE_D0) | 125 | && result == ACPI_STATE_D0) |
125 | device->parent->power.state = ACPI_STATE_D0; | 126 | device->parent->power.state = ACPI_STATE_D0; |
126 | 127 | ||
@@ -177,7 +178,8 @@ int acpi_device_set_power(struct acpi_device *device, int state) | |||
177 | acpi_power_state_string(state)); | 178 | acpi_power_state_string(state)); |
178 | return -ENODEV; | 179 | return -ENODEV; |
179 | } | 180 | } |
180 | if (device->parent && (state < device->parent->power.state)) { | 181 | if (!device->power.flags.ignore_parent && |
182 | device->parent && (state < device->parent->power.state)) { | ||
181 | dev_warn(&device->dev, | 183 | dev_warn(&device->dev, |
182 | "Cannot transition to power state %s for parent in %s\n", | 184 | "Cannot transition to power state %s for parent in %s\n", |
183 | acpi_power_state_string(state), | 185 | acpi_power_state_string(state), |
@@ -1025,60 +1027,4 @@ void acpi_dev_pm_detach(struct device *dev, bool power_off) | |||
1025 | } | 1027 | } |
1026 | } | 1028 | } |
1027 | EXPORT_SYMBOL_GPL(acpi_dev_pm_detach); | 1029 | EXPORT_SYMBOL_GPL(acpi_dev_pm_detach); |
1028 | |||
1029 | /** | ||
1030 | * acpi_dev_pm_add_dependent - Add physical device depending for PM. | ||
1031 | * @handle: Handle of ACPI device node. | ||
1032 | * @depdev: Device depending on that node for PM. | ||
1033 | */ | ||
1034 | void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev) | ||
1035 | { | ||
1036 | struct acpi_device_physical_node *dep; | ||
1037 | struct acpi_device *adev; | ||
1038 | |||
1039 | if (!depdev || acpi_bus_get_device(handle, &adev)) | ||
1040 | return; | ||
1041 | |||
1042 | mutex_lock(&adev->physical_node_lock); | ||
1043 | |||
1044 | list_for_each_entry(dep, &adev->power_dependent, node) | ||
1045 | if (dep->dev == depdev) | ||
1046 | goto out; | ||
1047 | |||
1048 | dep = kzalloc(sizeof(*dep), GFP_KERNEL); | ||
1049 | if (dep) { | ||
1050 | dep->dev = depdev; | ||
1051 | list_add_tail(&dep->node, &adev->power_dependent); | ||
1052 | } | ||
1053 | |||
1054 | out: | ||
1055 | mutex_unlock(&adev->physical_node_lock); | ||
1056 | } | ||
1057 | EXPORT_SYMBOL_GPL(acpi_dev_pm_add_dependent); | ||
1058 | |||
1059 | /** | ||
1060 | * acpi_dev_pm_remove_dependent - Remove physical device depending for PM. | ||
1061 | * @handle: Handle of ACPI device node. | ||
1062 | * @depdev: Device depending on that node for PM. | ||
1063 | */ | ||
1064 | void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev) | ||
1065 | { | ||
1066 | struct acpi_device_physical_node *dep; | ||
1067 | struct acpi_device *adev; | ||
1068 | |||
1069 | if (!depdev || acpi_bus_get_device(handle, &adev)) | ||
1070 | return; | ||
1071 | |||
1072 | mutex_lock(&adev->physical_node_lock); | ||
1073 | |||
1074 | list_for_each_entry(dep, &adev->power_dependent, node) | ||
1075 | if (dep->dev == depdev) { | ||
1076 | list_del(&dep->node); | ||
1077 | kfree(dep); | ||
1078 | break; | ||
1079 | } | ||
1080 | |||
1081 | mutex_unlock(&adev->physical_node_lock); | ||
1082 | } | ||
1083 | EXPORT_SYMBOL_GPL(acpi_dev_pm_remove_dependent); | ||
1084 | #endif /* CONFIG_PM */ | 1030 | #endif /* CONFIG_PM */ |