aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-11-24 18:11:24 -0500
committerLen Brown <len.brown@intel.com>2011-01-12 04:48:45 -0500
commit488a76c52606199100adf09c8eb7cbedbd94e9d9 (patch)
treebd5c7f8b546f881936d9c72989de7046c39fd755 /drivers/acpi
parentbf325f9538d8c89312be305b9779edbcb436af00 (diff)
ACPI / Fan: Rework the handling of power resources
Use the new function acpi_bus_update_power() for manipulating power resources used by ACPI fan devices, which allows them to be put into the right state during initialization and resume. Consequently, remove the flags.force_power_state field from struct acpi_device, which is not necessary any more. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/bus.c2
-rw-r--r--drivers/acpi/fan.c27
-rw-r--r--drivers/acpi/thermal.c5
3 files changed, 11 insertions, 23 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 47864013c0df..2ee83b5fff97 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -266,7 +266,7 @@ static int __acpi_bus_set_power(struct acpi_device *device, int state)
266 266
267 /* Make sure this is a valid target state */ 267 /* Make sure this is a valid target state */
268 268
269 if ((state == device->power.state) && !device->flags.force_power_state) { 269 if (state == device->power.state) {
270 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", 270 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n",
271 state)); 271 state));
272 return 0; 272 return 0;
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 60049080c869..467479f07c1f 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -86,7 +86,7 @@ static int fan_get_cur_state(struct thermal_cooling_device *cdev, unsigned long
86 if (!device) 86 if (!device)
87 return -EINVAL; 87 return -EINVAL;
88 88
89 result = acpi_bus_get_power(device->handle, &acpi_state); 89 result = acpi_bus_update_power(device->handle, &acpi_state);
90 if (result) 90 if (result)
91 return result; 91 return result;
92 92
@@ -123,7 +123,6 @@ static struct thermal_cooling_device_ops fan_cooling_ops = {
123static int acpi_fan_add(struct acpi_device *device) 123static int acpi_fan_add(struct acpi_device *device)
124{ 124{
125 int result = 0; 125 int result = 0;
126 int state = 0;
127 struct thermal_cooling_device *cdev; 126 struct thermal_cooling_device *cdev;
128 127
129 if (!device) 128 if (!device)
@@ -132,16 +131,12 @@ static int acpi_fan_add(struct acpi_device *device)
132 strcpy(acpi_device_name(device), "Fan"); 131 strcpy(acpi_device_name(device), "Fan");
133 strcpy(acpi_device_class(device), ACPI_FAN_CLASS); 132 strcpy(acpi_device_class(device), ACPI_FAN_CLASS);
134 133
135 result = acpi_bus_get_power(device->handle, &state); 134 result = acpi_bus_update_power(device->handle, NULL);
136 if (result) { 135 if (result) {
137 printk(KERN_ERR PREFIX "Reading power state\n"); 136 printk(KERN_ERR PREFIX "Setting initial power state\n");
138 goto end; 137 goto end;
139 } 138 }
140 139
141 device->flags.force_power_state = 1;
142 acpi_bus_set_power(device->handle, state);
143 device->flags.force_power_state = 0;
144
145 cdev = thermal_cooling_device_register("Fan", device, 140 cdev = thermal_cooling_device_register("Fan", device,
146 &fan_cooling_ops); 141 &fan_cooling_ops);
147 if (IS_ERR(cdev)) { 142 if (IS_ERR(cdev)) {
@@ -200,22 +195,14 @@ static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state)
200 195
201static int acpi_fan_resume(struct acpi_device *device) 196static int acpi_fan_resume(struct acpi_device *device)
202{ 197{
203 int result = 0; 198 int result;
204 int power_state = 0;
205 199
206 if (!device) 200 if (!device)
207 return -EINVAL; 201 return -EINVAL;
208 202
209 result = acpi_bus_get_power(device->handle, &power_state); 203 result = acpi_bus_update_power(device->handle, NULL);
210 if (result) { 204 if (result)
211 printk(KERN_ERR PREFIX 205 printk(KERN_ERR PREFIX "Error updating fan power state\n");
212 "Error reading fan power state\n");
213 return result;
214 }
215
216 device->flags.force_power_state = 1;
217 acpi_bus_set_power(device->handle, power_state);
218 device->flags.force_power_state = 0;
219 206
220 return result; 207 return result;
221} 208}
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 5a27b0a31315..2607e17b520f 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -1059,8 +1059,9 @@ static int acpi_thermal_resume(struct acpi_device *device)
1059 break; 1059 break;
1060 tz->trips.active[i].flags.enabled = 1; 1060 tz->trips.active[i].flags.enabled = 1;
1061 for (j = 0; j < tz->trips.active[i].devices.count; j++) { 1061 for (j = 0; j < tz->trips.active[i].devices.count; j++) {
1062 result = acpi_bus_get_power(tz->trips.active[i].devices. 1062 result = acpi_bus_update_power(
1063 handles[j], &power_state); 1063 tz->trips.active[i].devices.handles[j],
1064 &power_state);
1064 if (result || (power_state != ACPI_STATE_D0)) { 1065 if (result || (power_state != ACPI_STATE_D0)) {
1065 tz->trips.active[i].flags.enabled = 0; 1066 tz->trips.active[i].flags.enabled = 0;
1066 break; 1067 break;