diff options
author | Jean Delvare <khali@linux-fr.org> | 2007-12-03 17:28:42 -0500 |
---|---|---|
committer | Mark M. Hoffman <mhoffman@lightlink.com> | 2008-02-07 20:39:43 -0500 |
commit | 455f791ea3e33a274c098b4a8c2e35d4d1a6d518 (patch) | |
tree | b715b700c6173cefd46473f8c9670a94415ea117 /drivers/hwmon/lm85.c | |
parent | 4b4df95dccdd2c6a573c9dedefb747ed663c074d (diff) |
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 <khali@linux-fr.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon/lm85.c')
-rw-r--r-- | 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 194b8fb52f0e..9f1c6f1ee035 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 | |||
536 | return sprintf(buf, "%d\n", enable); | 536 | return sprintf(buf, "%d\n", enable); |
537 | } | 537 | } |
538 | 538 | ||
539 | static ssize_t set_pwm_enable(struct device *dev, struct device_attribute | ||
540 | *attr, const char *buf, size_t count) | ||
541 | { | ||
542 | int nr = to_sensor_dev_attr(attr)->index; | ||
543 | struct i2c_client *client = to_i2c_client(dev); | ||
544 | struct lm85_data *data = i2c_get_clientdata(client); | ||
545 | long val = simple_strtol(buf, NULL, 10); | ||
546 | u8 config; | ||
547 | |||
548 | switch (val) { | ||
549 | case 0: | ||
550 | config = 3; | ||
551 | break; | ||
552 | case 1: | ||
553 | config = 7; | ||
554 | break; | ||
555 | case 2: | ||
556 | /* Here we have to choose arbitrarily one of the 5 possible | ||
557 | configurations; I go for the safest */ | ||
558 | config = 6; | ||
559 | break; | ||
560 | default: | ||
561 | return -EINVAL; | ||
562 | } | ||
563 | |||
564 | mutex_lock(&data->update_lock); | ||
565 | data->autofan[nr].config = lm85_read_value(client, | ||
566 | LM85_REG_AFAN_CONFIG(nr)); | ||
567 | data->autofan[nr].config = (data->autofan[nr].config & ~0xe0) | ||
568 | | (config << 5); | ||
569 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), | ||
570 | data->autofan[nr].config); | ||
571 | mutex_unlock(&data->update_lock); | ||
572 | return count; | ||
573 | } | ||
574 | |||
539 | #define show_pwm_reg(offset) \ | 575 | #define show_pwm_reg(offset) \ |
540 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ | 576 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ |
541 | show_pwm, set_pwm, offset - 1); \ | 577 | show_pwm, set_pwm, offset - 1); \ |
542 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO, \ | 578 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ |
543 | show_pwm_enable, NULL, offset - 1) | 579 | show_pwm_enable, set_pwm_enable, offset - 1) |
544 | 580 | ||
545 | show_pwm_reg(1); | 581 | show_pwm_reg(1); |
546 | show_pwm_reg(2); | 582 | show_pwm_reg(2); |