Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=455f791ea3e33a274c098b4a8c2e35d4d1a6d518 Commit: 455f791ea3e33a274c098b4a8c2e35d4d1a6d518 Parent: 4b4df95dccdd2c6a573c9dedefb747ed663c074d Author: Jean Delvare <[EMAIL PROTECTED]> AuthorDate: Mon Dec 3 23:28:42 2007 +0100 Committer: Mark M. Hoffman <[EMAIL PROTECTED]> CommitDate: Thu Feb 7 20:39:43 2008 -0500
hwmon: (lm85) Make the pwmN_enable files writable Make the pwmN_enable files writable. This makes it possible to use standard fan speed control tools (pwmconfig, fancontrol) with the lm85 driver. I left the non-standard pwmN_auto_channels files in place, as they give additional control for the automatic mode, and some users might be used to them by now. Signed-off-by: Jean Delvare <[EMAIL PROTECTED]> Signed-off-by: Mark M. Hoffman <[EMAIL PROTECTED]> --- drivers/hwmon/lm85.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 194b8fb..9f1c6f1 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -536,11 +536,47 @@ static ssize_t show_pwm_enable(struct device *dev, struct device_attribute return sprintf(buf, "%d\n", enable); } +static ssize_t set_pwm_enable(struct device *dev, struct device_attribute + *attr, const char *buf, size_t count) +{ + int nr = to_sensor_dev_attr(attr)->index; + struct i2c_client *client = to_i2c_client(dev); + struct lm85_data *data = i2c_get_clientdata(client); + long val = simple_strtol(buf, NULL, 10); + u8 config; + + switch (val) { + case 0: + config = 3; + break; + case 1: + config = 7; + break; + case 2: + /* Here we have to choose arbitrarily one of the 5 possible + configurations; I go for the safest */ + config = 6; + break; + default: + return -EINVAL; + } + + mutex_lock(&data->update_lock); + data->autofan[nr].config = lm85_read_value(client, + LM85_REG_AFAN_CONFIG(nr)); + data->autofan[nr].config = (data->autofan[nr].config & ~0xe0) + | (config << 5); + lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), + data->autofan[nr].config); + mutex_unlock(&data->update_lock); + return count; +} + #define show_pwm_reg(offset) \ static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ show_pwm, set_pwm, offset - 1); \ -static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO, \ - show_pwm_enable, NULL, offset - 1) +static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ + show_pwm_enable, set_pwm_enable, offset - 1) show_pwm_reg(1); show_pwm_reg(2); - To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html