diff options
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/thinkpad_acpi.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 6b9300779a43..1dcf0660d8b5 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -5983,6 +5983,52 @@ static void fan_exit(void) | |||
5983 | flush_workqueue(tpacpi_wq); | 5983 | flush_workqueue(tpacpi_wq); |
5984 | } | 5984 | } |
5985 | 5985 | ||
5986 | static void fan_suspend(pm_message_t state) | ||
5987 | { | ||
5988 | if (!fan_control_allowed) | ||
5989 | return; | ||
5990 | |||
5991 | /* Store fan status in cache */ | ||
5992 | fan_get_status_safe(NULL); | ||
5993 | if (tp_features.fan_ctrl_status_undef) | ||
5994 | fan_control_desired_level = TP_EC_FAN_AUTO; | ||
5995 | } | ||
5996 | |||
5997 | static void fan_resume(void) | ||
5998 | { | ||
5999 | u8 saved_fan_level; | ||
6000 | u8 current_level = 7; | ||
6001 | bool do_set = false; | ||
6002 | |||
6003 | /* DSDT *always* updates status on resume */ | ||
6004 | tp_features.fan_ctrl_status_undef = 0; | ||
6005 | |||
6006 | saved_fan_level = fan_control_desired_level; | ||
6007 | if (!fan_control_allowed || | ||
6008 | (fan_get_status_safe(¤t_level) < 0)) | ||
6009 | return; | ||
6010 | |||
6011 | switch (fan_control_access_mode) { | ||
6012 | case TPACPI_FAN_WR_ACPI_SFAN: | ||
6013 | do_set = (saved_fan_level > current_level); | ||
6014 | break; | ||
6015 | case TPACPI_FAN_WR_ACPI_FANS: | ||
6016 | case TPACPI_FAN_WR_TPEC: | ||
6017 | do_set = ((saved_fan_level & TP_EC_FAN_FULLSPEED) || | ||
6018 | (saved_fan_level == 7 && | ||
6019 | !(current_level & TP_EC_FAN_FULLSPEED))); | ||
6020 | break; | ||
6021 | default: | ||
6022 | return; | ||
6023 | } | ||
6024 | if (do_set) { | ||
6025 | printk(TPACPI_NOTICE | ||
6026 | "restoring fan level to 0x%02x\n", | ||
6027 | saved_fan_level); | ||
6028 | fan_set_level_safe(saved_fan_level); | ||
6029 | } | ||
6030 | } | ||
6031 | |||
5986 | static int fan_read(char *p) | 6032 | static int fan_read(char *p) |
5987 | { | 6033 | { |
5988 | int len = 0; | 6034 | int len = 0; |
@@ -6174,6 +6220,8 @@ static struct ibm_struct fan_driver_data = { | |||
6174 | .read = fan_read, | 6220 | .read = fan_read, |
6175 | .write = fan_write, | 6221 | .write = fan_write, |
6176 | .exit = fan_exit, | 6222 | .exit = fan_exit, |
6223 | .suspend = fan_suspend, | ||
6224 | .resume = fan_resume, | ||
6177 | }; | 6225 | }; |
6178 | 6226 | ||
6179 | /**************************************************************************** | 6227 | /**************************************************************************** |