aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2007-04-27 21:00:09 -0400
committerLen Brown <len.brown@intel.com>2007-04-28 21:41:14 -0400
commitecf2a80a97b3d38ae008fa8a3cb98cd540ac1eae (patch)
tree2984d40ad016e7e9bb8aa05f63e238dea3bc817b
parent7d5a015eece8be9186d3613d595643a520555e33 (diff)
ACPI: thinkpad-acpi: add a fan-control feature master toggle
Len Brown considers that an active by default fan control interface in laptops may be too close to giving users enough rope. There is a good chance he is quite correct on this, especially if someone decides to use that interface in applets and users are not aware of its risks. This patch adds a master switch to thinkpad-acpi that enables or disables the entire fan-control feature as a module parameter: "fan_control". It defaults to disabled. Set it to non-zero to enable fan control. Also, the patch removes the expermiental status from fan control, since it is stable enough to not be called experimental, and the master switch makes it safe enough to do so. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--Documentation/thinkpad-acpi.txt15
-rw-r--r--drivers/misc/thinkpad_acpi.c30
-rw-r--r--drivers/misc/thinkpad_acpi.h2
3 files changed, 38 insertions, 9 deletions
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index eab4997efc0f..bca50d78a425 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -38,7 +38,7 @@ detailed description):
38 - Experimental: embedded controller register dump 38 - Experimental: embedded controller register dump
39 - LCD brightness control 39 - LCD brightness control
40 - Volume control 40 - Volume control
41 - Experimental: fan speed, fan enable/disable 41 - Fan control and monitoring: fan speed, fan enable/disable
42 - Experimental: WAN enable and disable 42 - Experimental: WAN enable and disable
43 43
44A compatibility table by model and feature is maintained on the web 44A compatibility table by model and feature is maintained on the web
@@ -681,21 +681,20 @@ distinct. The unmute the volume after the mute command, use either the
681up or down command (the level command will not unmute the volume). 681up or down command (the level command will not unmute the volume).
682The current volume level and mute state is shown in the file. 682The current volume level and mute state is shown in the file.
683 683
684EXPERIMENTAL: fan speed, fan enable/disable 684Fan control and monitoring: fan speed, fan enable/disable
685------------------------------------------- 685---------------------------------------------------------
686 686
687procfs: /proc/acpi/ibm/fan 687procfs: /proc/acpi/ibm/fan
688sysfs device attributes: (hwmon) fan_input, pwm1, pwm1_enable 688sysfs device attributes: (hwmon) fan_input, pwm1, pwm1_enable
689 689
690This feature is marked EXPERIMENTAL because the implementation 690NOTE NOTE NOTE: fan control operations are disabled by default for
691directly accesses hardware registers and may not work as expected. USE 691safety reasons. To enable them, the module parameter "fan_control=1"
692WITH CAUTION! To use this feature, you need to supply the 692must be given to thinkpad-acpi.
693experimental=1 parameter when loading the module.
694 693
695This feature attempts to show the current fan speed, control mode and 694This feature attempts to show the current fan speed, control mode and
696other fan data that might be available. The speed is read directly 695other fan data that might be available. The speed is read directly
697from the hardware registers of the embedded controller. This is known 696from the hardware registers of the embedded controller. This is known
698to work on later R, T and X series ThinkPads but may show a bogus 697to work on later R, T, X and Z series ThinkPads but may show a bogus
699value on other models. 698value on other models.
700 699
701Fan levels: 700Fan levels:
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index c0a023cc5ded..7dc3a2206195 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -2935,6 +2935,9 @@ static ssize_t fan_fan_watchdog_store(struct device_driver *drv,
2935 if (parse_strtoul(buf, 120, &t)) 2935 if (parse_strtoul(buf, 120, &t))
2936 return -EINVAL; 2936 return -EINVAL;
2937 2937
2938 if (!fan_control_allowed)
2939 return -EPERM;
2940
2938 fan_watchdog_maxinterval = t; 2941 fan_watchdog_maxinterval = t;
2939 fan_watchdog_reset(); 2942 fan_watchdog_reset();
2940 2943
@@ -3046,6 +3049,14 @@ static int __init fan_init(struct ibm_init_struct *iibm)
3046 fan_control_access_mode != TPACPI_FAN_WR_NONE), 3049 fan_control_access_mode != TPACPI_FAN_WR_NONE),
3047 fan_status_access_mode, fan_control_access_mode); 3050 fan_status_access_mode, fan_control_access_mode);
3048 3051
3052 /* fan control master switch */
3053 if (!fan_control_allowed) {
3054 fan_control_access_mode = TPACPI_FAN_WR_NONE;
3055 fan_control_commands = 0;
3056 dbg_printk(TPACPI_DBG_INIT,
3057 "fan control features disabled by parameter\n");
3058 }
3059
3049 /* update fan_control_desired_level */ 3060 /* update fan_control_desired_level */
3050 if (fan_status_access_mode != TPACPI_FAN_NONE) 3061 if (fan_status_access_mode != TPACPI_FAN_NONE)
3051 fan_get_status_safe(NULL); 3062 fan_get_status_safe(NULL);
@@ -3203,6 +3214,9 @@ static void fan_watchdog_reset(void)
3203 3214
3204static int fan_set_level(int level) 3215static int fan_set_level(int level)
3205{ 3216{
3217 if (!fan_control_allowed)
3218 return -EPERM;
3219
3206 switch (fan_control_access_mode) { 3220 switch (fan_control_access_mode) {
3207 case TPACPI_FAN_WR_ACPI_SFAN: 3221 case TPACPI_FAN_WR_ACPI_SFAN:
3208 if (level >= 0 && level <= 7) { 3222 if (level >= 0 && level <= 7) {
@@ -3242,6 +3256,9 @@ static int fan_set_level_safe(int level)
3242{ 3256{
3243 int rc; 3257 int rc;
3244 3258
3259 if (!fan_control_allowed)
3260 return -EPERM;
3261
3245 rc = mutex_lock_interruptible(&fan_mutex); 3262 rc = mutex_lock_interruptible(&fan_mutex);
3246 if (rc < 0) 3263 if (rc < 0)
3247 return rc; 3264 return rc;
@@ -3262,6 +3279,9 @@ static int fan_set_enable(void)
3262 u8 s; 3279 u8 s;
3263 int rc; 3280 int rc;
3264 3281
3282 if (!fan_control_allowed)
3283 return -EPERM;
3284
3265 rc = mutex_lock_interruptible(&fan_mutex); 3285 rc = mutex_lock_interruptible(&fan_mutex);
3266 if (rc < 0) 3286 if (rc < 0)
3267 return rc; 3287 return rc;
@@ -3315,6 +3335,9 @@ static int fan_set_disable(void)
3315{ 3335{
3316 int rc; 3336 int rc;
3317 3337
3338 if (!fan_control_allowed)
3339 return -EPERM;
3340
3318 rc = mutex_lock_interruptible(&fan_mutex); 3341 rc = mutex_lock_interruptible(&fan_mutex);
3319 if (rc < 0) 3342 if (rc < 0)
3320 return rc; 3343 return rc;
@@ -3351,6 +3374,9 @@ static int fan_set_speed(int speed)
3351{ 3374{
3352 int rc; 3375 int rc;
3353 3376
3377 if (!fan_control_allowed)
3378 return -EPERM;
3379
3354 rc = mutex_lock_interruptible(&fan_mutex); 3380 rc = mutex_lock_interruptible(&fan_mutex);
3355 if (rc < 0) 3381 if (rc < 0)
3356 return rc; 3382 return rc;
@@ -3558,7 +3584,6 @@ static struct ibm_struct fan_driver_data = {
3558 .read = fan_read, 3584 .read = fan_read,
3559 .write = fan_write, 3585 .write = fan_write,
3560 .exit = fan_exit, 3586 .exit = fan_exit,
3561 .flags.experimental = 1,
3562}; 3587};
3563 3588
3564/**************************************************************************** 3589/****************************************************************************
@@ -3879,6 +3904,9 @@ module_param_named(debug, dbg_level, uint, 0);
3879static int force_load; 3904static int force_load;
3880module_param(force_load, int, 0); 3905module_param(force_load, int, 0);
3881 3906
3907static int fan_control_allowed;
3908module_param_named(fan_control, fan_control_allowed, int, 0);
3909
3882#define IBM_PARAM(feature) \ 3910#define IBM_PARAM(feature) \
3883 module_param_call(feature, set_ibm_param, NULL, NULL, 0) 3911 module_param_call(feature, set_ibm_param, NULL, NULL, 0)
3884 3912
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 8348fc653009..a9e709368256 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -375,6 +375,8 @@ enum fan_control_commands {
375 * and also watchdog cmd */ 375 * and also watchdog cmd */
376}; 376};
377 377
378static int fan_control_allowed;
379
378static enum fan_status_access_mode fan_status_access_mode; 380static enum fan_status_access_mode fan_status_access_mode;
379static enum fan_control_access_mode fan_control_access_mode; 381static enum fan_control_access_mode fan_control_access_mode;
380static enum fan_control_commands fan_control_commands; 382static enum fan_control_commands fan_control_commands;