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 a5a5532db268..a6e149d692cb 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
@@ -47,6 +47,8 @@ MODULE_LICENSE("GPL"); | |||
47 | 47 | ||
48 | static int acpi_fan_add(struct acpi_device *device); | 48 | static int acpi_fan_add(struct acpi_device *device); |
49 | static int acpi_fan_remove(struct acpi_device *device, int type); | 49 | static int acpi_fan_remove(struct acpi_device *device, int type); |
50 | static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state); | ||
51 | static int acpi_fan_resume(struct acpi_device *device); | ||
50 | 52 | ||
51 | static const struct acpi_device_id fan_device_ids[] = { | 53 | static const struct acpi_device_id fan_device_ids[] = { |
52 | {"PNP0C0B", 0}, | 54 | {"PNP0C0B", 0}, |
@@ -61,6 +63,8 @@ static struct acpi_driver acpi_fan_driver = { | |||
61 | .ops = { | 63 | .ops = { |
62 | .add = acpi_fan_add, | 64 | .add = acpi_fan_add, |
63 | .remove = acpi_fan_remove, | 65 | .remove = acpi_fan_remove, |
66 | .suspend = acpi_fan_suspend, | ||
67 | .resume = acpi_fan_resume, | ||
64 | }, | 68 | }, |
65 | }; | 69 | }; |
66 | 70 | ||
@@ -191,6 +195,10 @@ static int acpi_fan_add(struct acpi_device *device) | |||
191 | goto end; | 195 | goto end; |
192 | } | 196 | } |
193 | 197 | ||
198 | device->flags.force_power_state = 1; | ||
199 | acpi_bus_set_power(device->handle, state); | ||
200 | device->flags.force_power_state = 0; | ||
201 | |||
194 | result = acpi_fan_add_fs(device); | 202 | result = acpi_fan_add_fs(device); |
195 | if (result) | 203 | if (result) |
196 | goto end; | 204 | goto end; |
@@ -216,6 +224,38 @@ static int acpi_fan_remove(struct acpi_device *device, int type) | |||
216 | return 0; | 224 | return 0; |
217 | } | 225 | } |
218 | 226 | ||
227 | static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state) | ||
228 | { | ||
229 | if (!device) | ||
230 | return -EINVAL; | ||
231 | |||
232 | acpi_bus_set_power(device->handle, ACPI_STATE_D0); | ||
233 | |||
234 | return AE_OK; | ||
235 | } | ||
236 | |||
237 | static int acpi_fan_resume(struct acpi_device *device) | ||
238 | { | ||
239 | int result = 0; | ||
240 | int power_state = 0; | ||
241 | |||
242 | if (!device) | ||
243 | return -EINVAL; | ||
244 | |||
245 | result = acpi_bus_get_power(device->handle, &power_state); | ||
246 | if (result) { | ||
247 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
248 | "Error reading fan power state\n")); | ||
249 | return result; | ||
250 | } | ||
251 | |||
252 | device->flags.force_power_state = 1; | ||
253 | acpi_bus_set_power(device->handle, power_state); | ||
254 | device->flags.force_power_state = 0; | ||
255 | |||
256 | return result; | ||
257 | } | ||
258 | |||
219 | static int __init acpi_fan_init(void) | 259 | static int __init acpi_fan_init(void) |
220 | { | 260 | { |
221 | int result = 0; | 261 | int result = 0; |