diff options
Diffstat (limited to 'drivers/acpi/fan.c')
-rw-r--r-- | drivers/acpi/fan.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index e8165c4f162a..1cd25784b7a4 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
@@ -48,6 +48,8 @@ MODULE_LICENSE("GPL"); | |||
48 | 48 | ||
49 | static int acpi_fan_add(struct acpi_device *device); | 49 | static int acpi_fan_add(struct acpi_device *device); |
50 | static int acpi_fan_remove(struct acpi_device *device, int type); | 50 | static int acpi_fan_remove(struct acpi_device *device, int type); |
51 | static int acpi_fan_suspend(struct acpi_device *device, int state); | ||
52 | static int acpi_fan_resume(struct acpi_device *device, int state); | ||
51 | 53 | ||
52 | static struct acpi_driver acpi_fan_driver = { | 54 | static struct acpi_driver acpi_fan_driver = { |
53 | .name = ACPI_FAN_DRIVER_NAME, | 55 | .name = ACPI_FAN_DRIVER_NAME, |
@@ -56,6 +58,8 @@ static struct acpi_driver acpi_fan_driver = { | |||
56 | .ops = { | 58 | .ops = { |
57 | .add = acpi_fan_add, | 59 | .add = acpi_fan_add, |
58 | .remove = acpi_fan_remove, | 60 | .remove = acpi_fan_remove, |
61 | .suspend = acpi_fan_suspend, | ||
62 | .resume = acpi_fan_resume, | ||
59 | }, | 63 | }, |
60 | }; | 64 | }; |
61 | 65 | ||
@@ -206,6 +210,10 @@ static int acpi_fan_add(struct acpi_device *device) | |||
206 | goto end; | 210 | goto end; |
207 | } | 211 | } |
208 | 212 | ||
213 | device->flags.force_power_state = 1; | ||
214 | acpi_bus_set_power(device->handle, state); | ||
215 | device->flags.force_power_state = 0; | ||
216 | |||
209 | result = acpi_fan_add_fs(device); | 217 | result = acpi_fan_add_fs(device); |
210 | if (result) | 218 | if (result) |
211 | goto end; | 219 | goto end; |
@@ -239,6 +247,38 @@ static int acpi_fan_remove(struct acpi_device *device, int type) | |||
239 | return_VALUE(0); | 247 | return_VALUE(0); |
240 | } | 248 | } |
241 | 249 | ||
250 | static int acpi_fan_suspend(struct acpi_device *device, int state) | ||
251 | { | ||
252 | if (!device) | ||
253 | return -EINVAL; | ||
254 | |||
255 | acpi_bus_set_power(device->handle, ACPI_STATE_D0); | ||
256 | |||
257 | return AE_OK; | ||
258 | } | ||
259 | |||
260 | static int acpi_fan_resume(struct acpi_device *device, int state) | ||
261 | { | ||
262 | int result = 0; | ||
263 | int power_state = 0; | ||
264 | |||
265 | if (!device) | ||
266 | return -EINVAL; | ||
267 | |||
268 | result = acpi_bus_get_power(device->handle, &power_state); | ||
269 | if (result) { | ||
270 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
271 | "Error reading fan power state\n")); | ||
272 | return result; | ||
273 | } | ||
274 | |||
275 | device->flags.force_power_state = 1; | ||
276 | acpi_bus_set_power(device->handle, power_state); | ||
277 | device->flags.force_power_state = 0; | ||
278 | |||
279 | return result; | ||
280 | } | ||
281 | |||
242 | static int __init acpi_fan_init(void) | 282 | static int __init acpi_fan_init(void) |
243 | { | 283 | { |
244 | int result = 0; | 284 | int result = 0; |