Skip to content

Commit

Permalink
ACPI: thinkpad-acpi: add a fan-control feature master toggle
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
hmh authored and lenb committed Apr 29, 2007
1 parent 7d5a015 commit ecf2a80
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
15 changes: 7 additions & 8 deletions Documentation/thinkpad-acpi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ detailed description):
- Experimental: embedded controller register dump
- LCD brightness control
- Volume control
- Experimental: fan speed, fan enable/disable
- Fan control and monitoring: fan speed, fan enable/disable
- Experimental: WAN enable and disable

A compatibility table by model and feature is maintained on the web
Expand Down Expand Up @@ -681,21 +681,20 @@ distinct. The unmute the volume after the mute command, use either the
up or down command (the level command will not unmute the volume).
The current volume level and mute state is shown in the file.

EXPERIMENTAL: fan speed, fan enable/disable
-------------------------------------------
Fan control and monitoring: fan speed, fan enable/disable
---------------------------------------------------------

procfs: /proc/acpi/ibm/fan
sysfs device attributes: (hwmon) fan_input, pwm1, pwm1_enable

This feature is marked EXPERIMENTAL because the implementation
directly accesses hardware registers and may not work as expected. USE
WITH CAUTION! To use this feature, you need to supply the
experimental=1 parameter when loading the module.
NOTE NOTE NOTE: fan control operations are disabled by default for
safety reasons. To enable them, the module parameter "fan_control=1"
must be given to thinkpad-acpi.

This feature attempts to show the current fan speed, control mode and
other fan data that might be available. The speed is read directly
from the hardware registers of the embedded controller. This is known
to work on later R, T and X series ThinkPads but may show a bogus
to work on later R, T, X and Z series ThinkPads but may show a bogus
value on other models.

Fan levels:
Expand Down
30 changes: 29 additions & 1 deletion drivers/misc/thinkpad_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2935,6 +2935,9 @@ static ssize_t fan_fan_watchdog_store(struct device_driver *drv,
if (parse_strtoul(buf, 120, &t))
return -EINVAL;

if (!fan_control_allowed)
return -EPERM;

fan_watchdog_maxinterval = t;
fan_watchdog_reset();

Expand Down Expand Up @@ -3046,6 +3049,14 @@ static int __init fan_init(struct ibm_init_struct *iibm)
fan_control_access_mode != TPACPI_FAN_WR_NONE),
fan_status_access_mode, fan_control_access_mode);

/* fan control master switch */
if (!fan_control_allowed) {
fan_control_access_mode = TPACPI_FAN_WR_NONE;
fan_control_commands = 0;
dbg_printk(TPACPI_DBG_INIT,
"fan control features disabled by parameter\n");
}

/* update fan_control_desired_level */
if (fan_status_access_mode != TPACPI_FAN_NONE)
fan_get_status_safe(NULL);
Expand Down Expand Up @@ -3203,6 +3214,9 @@ static void fan_watchdog_reset(void)

static int fan_set_level(int level)
{
if (!fan_control_allowed)
return -EPERM;

switch (fan_control_access_mode) {
case TPACPI_FAN_WR_ACPI_SFAN:
if (level >= 0 && level <= 7) {
Expand Down Expand Up @@ -3242,6 +3256,9 @@ static int fan_set_level_safe(int level)
{
int rc;

if (!fan_control_allowed)
return -EPERM;

rc = mutex_lock_interruptible(&fan_mutex);
if (rc < 0)
return rc;
Expand All @@ -3262,6 +3279,9 @@ static int fan_set_enable(void)
u8 s;
int rc;

if (!fan_control_allowed)
return -EPERM;

rc = mutex_lock_interruptible(&fan_mutex);
if (rc < 0)
return rc;
Expand Down Expand Up @@ -3315,6 +3335,9 @@ static int fan_set_disable(void)
{
int rc;

if (!fan_control_allowed)
return -EPERM;

rc = mutex_lock_interruptible(&fan_mutex);
if (rc < 0)
return rc;
Expand Down Expand Up @@ -3351,6 +3374,9 @@ static int fan_set_speed(int speed)
{
int rc;

if (!fan_control_allowed)
return -EPERM;

rc = mutex_lock_interruptible(&fan_mutex);
if (rc < 0)
return rc;
Expand Down Expand Up @@ -3558,7 +3584,6 @@ static struct ibm_struct fan_driver_data = {
.read = fan_read,
.write = fan_write,
.exit = fan_exit,
.flags.experimental = 1,
};

/****************************************************************************
Expand Down Expand Up @@ -3879,6 +3904,9 @@ module_param_named(debug, dbg_level, uint, 0);
static int force_load;
module_param(force_load, int, 0);

static int fan_control_allowed;
module_param_named(fan_control, fan_control_allowed, int, 0);

#define IBM_PARAM(feature) \
module_param_call(feature, set_ibm_param, NULL, NULL, 0)

Expand Down
2 changes: 2 additions & 0 deletions drivers/misc/thinkpad_acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ enum fan_control_commands {
* and also watchdog cmd */
};

static int fan_control_allowed;

static enum fan_status_access_mode fan_status_access_mode;
static enum fan_control_access_mode fan_control_access_mode;
static enum fan_control_commands fan_control_commands;
Expand Down

0 comments on commit ecf2a80

Please sign in to comment.