aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/fan.c
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/fan.c
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/fan.c')
-rw-r--r--drivers/acpi/fan.c27
1 files changed, 7 insertions, 20 deletions
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}