aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2009-06-15 12:39:50 -0400
committerJean Delvare <khali@linux-fr.org>2009-06-15 12:39:50 -0400
commit3fc7838a20cdd9aab0077f355b8c44135cd4b6bd (patch)
tree8437fbfd39f0d210286988e104d3228af77d1e5f
parent2958b1ec6be1d71105d67d70de9d7d70f5e97151 (diff)
hwmon: (f71882fg) Cleanup f8000 pwm handling
Currently we are using separate per model sysfs attr for the 3th pwm, because the 3th pwm of the f8000 only has automatic mode and not manual mode. Doing things this way was getting in the way for adding f71858fg support, so this patch makes the pwm attr identical for all models, and instead adds a check to store_pwm_enable() disallowing setting the 3th pwm to manual mode on a f8000 IC. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r--drivers/hwmon/f71882fg.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
index 4639b2a4b815..eb324e604105 100644
--- a/drivers/hwmon/f71882fg.c
+++ b/drivers/hwmon/f71882fg.c
@@ -1,6 +1,6 @@
1/*************************************************************************** 1/***************************************************************************
2 * Copyright (C) 2006 by Hans Edgington <hans@edgington.nl> * 2 * Copyright (C) 2006 by Hans Edgington <hans@edgington.nl> *
3 * Copyright (C) 2007,2008 by Hans de Goede <hdegoede@redhat.com> * 3 * Copyright (C) 2007-2009 Hans de Goede <hdegoede@redhat.com> *
4 * * 4 * *
5 * This program is free software; you can redistribute it and/or modify * 5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by * 6 * it under the terms of the GNU General Public License as published by *
@@ -395,6 +395,9 @@ static struct sensor_device_attribute_2 fxxxx_fan_attr[] = {
395 show_pwm_auto_point_channel, 395 show_pwm_auto_point_channel,
396 store_pwm_auto_point_channel, 0, 1), 396 store_pwm_auto_point_channel, 0, 1),
397 397
398 SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2),
399 SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
400 store_pwm_enable, 0, 2),
398 SENSOR_ATTR_2(pwm3_interpolate, S_IRUGO|S_IWUSR, 401 SENSOR_ATTR_2(pwm3_interpolate, S_IRUGO|S_IWUSR,
399 show_pwm_interpolate, store_pwm_interpolate, 0, 2), 402 show_pwm_interpolate, store_pwm_interpolate, 0, 2),
400 SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, 403 SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR,
@@ -450,9 +453,6 @@ static struct sensor_device_attribute_2 f71862fg_fan_attr[] = {
450 SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO, 453 SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO,
451 show_pwm_auto_point_temp_hyst, NULL, 3, 1), 454 show_pwm_auto_point_temp_hyst, NULL, 3, 1),
452 455
453 SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2),
454 SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
455 store_pwm_enable, 0, 2),
456 SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, 456 SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR,
457 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, 457 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
458 1, 2), 458 1, 2),
@@ -565,9 +565,6 @@ static struct sensor_device_attribute_2 f71882fg_fan_attr[] = {
565 SENSOR_ATTR_2(pwm2_auto_point4_temp_hyst, S_IRUGO, 565 SENSOR_ATTR_2(pwm2_auto_point4_temp_hyst, S_IRUGO,
566 show_pwm_auto_point_temp_hyst, NULL, 3, 1), 566 show_pwm_auto_point_temp_hyst, NULL, 3, 1),
567 567
568 SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2),
569 SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
570 store_pwm_enable, 0, 2),
571 SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, 568 SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR,
572 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, 569 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
573 0, 2), 570 0, 2),
@@ -659,8 +656,6 @@ static struct sensor_device_attribute_2 f71882fg_fan_attr[] = {
659static struct sensor_device_attribute_2 f8000_fan_attr[] = { 656static struct sensor_device_attribute_2 f8000_fan_attr[] = {
660 SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), 657 SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3),
661 658
662 SENSOR_ATTR_2(pwm3, S_IRUGO, show_pwm, NULL, 0, 2),
663
664 SENSOR_ATTR_2(temp1_auto_point1_pwm, S_IRUGO|S_IWUSR, 659 SENSOR_ATTR_2(temp1_auto_point1_pwm, S_IRUGO|S_IWUSR,
665 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, 660 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
666 0, 2), 661 0, 2),
@@ -1440,6 +1435,10 @@ static ssize_t store_pwm_enable(struct device *dev, struct device_attribute
1440 int nr = to_sensor_dev_attr_2(devattr)->index; 1435 int nr = to_sensor_dev_attr_2(devattr)->index;
1441 long val = simple_strtol(buf, NULL, 10); 1436 long val = simple_strtol(buf, NULL, 10);
1442 1437
1438 /* Special case for F8000 pwm channel 3 which only does auto mode */
1439 if (data->type == f8000 && nr == 2 && val != 2)
1440 return -EINVAL;
1441
1443 mutex_lock(&data->update_lock); 1442 mutex_lock(&data->update_lock);
1444 data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); 1443 data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE);
1445 /* Special case for F8000 auto PWM mode / Thermostat mode */ 1444 /* Special case for F8000 auto PWM mode / Thermostat mode */