Commit dfc216c6 authored by Jonas Munsin's avatar Jonas Munsin Committed by Greg Kroah-Hartman

[PATCH] I2C: fix it87 sensor driver stops CPU fan

> 2* I would then add a check to the it87 driver, which completely disables
> the fan speed control interface if the initial configuration looks weird
> (all fans supposedly stopped and polarity set to "active low"). This
> should protect users of the driver who have a faulty BIOS.
>
> When a bogus configuration is detected, we would of course complain in
> the logs and invite the user to complain to his/her motherboard maker
> too.

Here is it87.c_2.6.10-jm4-detect_broken_bios_20050112.diff implementing
this. It goes on top of the previous patch.

- detects broken bioses, disables the pwm for them and prints a message
- fixes an unrelated minor bug in set_fan_div()
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarJonas Munsin <jmunsin@iki.fi>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 0b28a61a
......@@ -500,7 +500,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
else
data->fan_div[nr] = 3;
}
val = old & 0x100;
val = old & 0x80;
val |= (data->fan_div[0] & 0x07);
val |= (data->fan_div[1] & 0x07) << 3;
if (data->fan_div[2] == 3)
......@@ -703,6 +703,8 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
int err = 0;
const char *name = "";
int is_isa = i2c_is_isa_adapter(adapter);
int enable_pwm_interface;
int tmp;
if (!is_isa &&
!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
......@@ -812,6 +814,17 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
/* Initialize the IT87 chip */
it87_init_client(new_client, data);
/* Some BIOSes fail to correctly configure the IT87 fans. All fans off
* and polarity set to active low is sign that this is the case so we
* disable pwm control to protect the user. */
enable_pwm_interface = 1;
tmp = it87_read_value(new_client, IT87_REG_FAN_CTL);
if ((tmp & 0x87) == 0) {
enable_pwm_interface = 0;
dev_info(&new_client->dev,
"detected broken BIOS defaults, disabling pwm interface");
}
/* Register sysfs hooks */
device_create_file(&new_client->dev, &dev_attr_in0_input);
device_create_file(&new_client->dev, &dev_attr_in1_input);
......@@ -860,12 +873,14 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
device_create_file(&new_client->dev, &dev_attr_fan2_div);
device_create_file(&new_client->dev, &dev_attr_fan3_div);
device_create_file(&new_client->dev, &dev_attr_alarms);
device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
device_create_file(&new_client->dev, &dev_attr_pwm2_enable);
device_create_file(&new_client->dev, &dev_attr_pwm3_enable);
device_create_file(&new_client->dev, &dev_attr_pwm1);
device_create_file(&new_client->dev, &dev_attr_pwm2);
device_create_file(&new_client->dev, &dev_attr_pwm3);
if (enable_pwm_interface) {
device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
device_create_file(&new_client->dev, &dev_attr_pwm2_enable);
device_create_file(&new_client->dev, &dev_attr_pwm3_enable);
device_create_file(&new_client->dev, &dev_attr_pwm1);
device_create_file(&new_client->dev, &dev_attr_pwm2);
device_create_file(&new_client->dev, &dev_attr_pwm3);
}
if (data->type == it8712) {
device_create_file_vrm(new_client);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment