aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/thinkpad_acpi.c
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2008-12-04 01:16:36 -0500
committerJames Morris <jmorris@namei.org>2008-12-04 01:16:36 -0500
commitec98ce480ada787f2cfbd696980ff3564415505b (patch)
tree1a4d644b38f9f1e4b4e086fde0b195df4a92cf84 /drivers/misc/thinkpad_acpi.c
parent3496f92beb9aa99ef21fccc154a36c7698e9c538 (diff)
parentfeaf3848a813a106f163013af6fcf6c4bfec92d9 (diff)
Merge branch 'master' into next
Conflicts: fs/nfsd/nfs4recover.c Manually fixed above to use new creds API functions, e.g. nfs4_save_creds(). Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'drivers/misc/thinkpad_acpi.c')
-rw-r--r--drivers/misc/thinkpad_acpi.c57
1 files changed, 45 insertions, 12 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 7a4a26b0edd2..899766e16fa8 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -5318,6 +5318,7 @@ static enum fan_control_commands fan_control_commands;
5318 5318
5319static u8 fan_control_initial_status; 5319static u8 fan_control_initial_status;
5320static u8 fan_control_desired_level; 5320static u8 fan_control_desired_level;
5321static u8 fan_control_resume_level;
5321static int fan_watchdog_maxinterval; 5322static int fan_watchdog_maxinterval;
5322 5323
5323static struct mutex fan_mutex; 5324static struct mutex fan_mutex;
@@ -5440,8 +5441,8 @@ static int fan_set_level(int level)
5440 5441
5441 case TPACPI_FAN_WR_ACPI_FANS: 5442 case TPACPI_FAN_WR_ACPI_FANS:
5442 case TPACPI_FAN_WR_TPEC: 5443 case TPACPI_FAN_WR_TPEC:
5443 if ((level != TP_EC_FAN_AUTO) && 5444 if (!(level & TP_EC_FAN_AUTO) &&
5444 (level != TP_EC_FAN_FULLSPEED) && 5445 !(level & TP_EC_FAN_FULLSPEED) &&
5445 ((level < 0) || (level > 7))) 5446 ((level < 0) || (level > 7)))
5446 return -EINVAL; 5447 return -EINVAL;
5447 5448
@@ -6005,38 +6006,67 @@ static void fan_exit(void)
6005 6006
6006static void fan_suspend(pm_message_t state) 6007static void fan_suspend(pm_message_t state)
6007{ 6008{
6009 int rc;
6010
6008 if (!fan_control_allowed) 6011 if (!fan_control_allowed)
6009 return; 6012 return;
6010 6013
6011 /* Store fan status in cache */ 6014 /* Store fan status in cache */
6012 fan_get_status_safe(NULL); 6015 fan_control_resume_level = 0;
6016 rc = fan_get_status_safe(&fan_control_resume_level);
6017 if (rc < 0)
6018 printk(TPACPI_NOTICE
6019 "failed to read fan level for later "
6020 "restore during resume: %d\n", rc);
6021
6022 /* if it is undefined, don't attempt to restore it.
6023 * KEEP THIS LAST */
6013 if (tp_features.fan_ctrl_status_undef) 6024 if (tp_features.fan_ctrl_status_undef)
6014 fan_control_desired_level = TP_EC_FAN_AUTO; 6025 fan_control_resume_level = 0;
6015} 6026}
6016 6027
6017static void fan_resume(void) 6028static void fan_resume(void)
6018{ 6029{
6019 u8 saved_fan_level;
6020 u8 current_level = 7; 6030 u8 current_level = 7;
6021 bool do_set = false; 6031 bool do_set = false;
6032 int rc;
6022 6033
6023 /* DSDT *always* updates status on resume */ 6034 /* DSDT *always* updates status on resume */
6024 tp_features.fan_ctrl_status_undef = 0; 6035 tp_features.fan_ctrl_status_undef = 0;
6025 6036
6026 saved_fan_level = fan_control_desired_level;
6027 if (!fan_control_allowed || 6037 if (!fan_control_allowed ||
6038 !fan_control_resume_level ||
6028 (fan_get_status_safe(&current_level) < 0)) 6039 (fan_get_status_safe(&current_level) < 0))
6029 return; 6040 return;
6030 6041
6031 switch (fan_control_access_mode) { 6042 switch (fan_control_access_mode) {
6032 case TPACPI_FAN_WR_ACPI_SFAN: 6043 case TPACPI_FAN_WR_ACPI_SFAN:
6033 do_set = (saved_fan_level > current_level); 6044 /* never decrease fan level */
6045 do_set = (fan_control_resume_level > current_level);
6034 break; 6046 break;
6035 case TPACPI_FAN_WR_ACPI_FANS: 6047 case TPACPI_FAN_WR_ACPI_FANS:
6036 case TPACPI_FAN_WR_TPEC: 6048 case TPACPI_FAN_WR_TPEC:
6037 do_set = ((saved_fan_level & TP_EC_FAN_FULLSPEED) || 6049 /* never decrease fan level, scale is:
6038 (saved_fan_level == 7 && 6050 * TP_EC_FAN_FULLSPEED > 7 >= TP_EC_FAN_AUTO
6039 !(current_level & TP_EC_FAN_FULLSPEED))); 6051 *
6052 * We expect the firmware to set either 7 or AUTO, but we
6053 * handle FULLSPEED out of paranoia.
6054 *
6055 * So, we can safely only restore FULLSPEED or 7, anything
6056 * else could slow the fan. Restoring AUTO is useless, at
6057 * best that's exactly what the DSDT already set (it is the
6058 * slower it uses).
6059 *
6060 * Always keep in mind that the DSDT *will* have set the
6061 * fans to what the vendor supposes is the best level. We
6062 * muck with it only to speed the fan up.
6063 */
6064 if (fan_control_resume_level != 7 &&
6065 !(fan_control_resume_level & TP_EC_FAN_FULLSPEED))
6066 return;
6067 else
6068 do_set = !(current_level & TP_EC_FAN_FULLSPEED) &&
6069 (current_level != fan_control_resume_level);
6040 break; 6070 break;
6041 default: 6071 default:
6042 return; 6072 return;
@@ -6044,8 +6074,11 @@ static void fan_resume(void)
6044 if (do_set) { 6074 if (do_set) {
6045 printk(TPACPI_NOTICE 6075 printk(TPACPI_NOTICE
6046 "restoring fan level to 0x%02x\n", 6076 "restoring fan level to 0x%02x\n",
6047 saved_fan_level); 6077 fan_control_resume_level);
6048 fan_set_level_safe(saved_fan_level); 6078 rc = fan_set_level_safe(fan_control_resume_level);
6079 if (rc < 0)
6080 printk(TPACPI_NOTICE
6081 "failed to restore fan level: %d\n", rc);
6049 } 6082 }
6050} 6083}
6051 6084