aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83795.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-10-28 14:31:46 -0400
committerJean Delvare <khali@endymion.delvare>2010-10-28 14:31:46 -0400
commitb5f6a90a0bbedc07a0b0b82b83aa716c7203fcd2 (patch)
tree6a37212c0c55fda155c239bead95c7ef8b2c1483 /drivers/hwmon/w83795.c
parent87df0dad3e024538d2d0d2ce786230e639c2ea8b (diff)
hwmon: (w83795) Move PWM attributes to a dedidated array
Use a dedicated 2D array for PWM attributes. This way, PWM attributes are handled the same way as other attributes, this is more consistent. Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/w83795.c')
-rw-r--r--drivers/hwmon/w83795.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c
index 393f1025f6c8..76e89c7bc465 100644
--- a/drivers/hwmon/w83795.c
+++ b/drivers/hwmon/w83795.c
@@ -1470,7 +1470,7 @@ store_sf_setup(struct device *dev, struct device_attribute *attr,
1470 SENSOR_ATTR_2(fan##index##_beep, S_IWUSR | S_IRUGO, \ 1470 SENSOR_ATTR_2(fan##index##_beep, S_IWUSR | S_IRUGO, \
1471 show_alarm_beep, store_beep, BEEP_ENABLE, index + 31) } 1471 show_alarm_beep, store_beep, BEEP_ENABLE, index + 31) }
1472 1472
1473#define SENSOR_ATTR_PWM(index) \ 1473#define SENSOR_ATTR_PWM(index) { \
1474 SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm, \ 1474 SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm, \
1475 store_pwm, PWM_OUTPUT, index - 1), \ 1475 store_pwm, PWM_OUTPUT, index - 1), \
1476 SENSOR_ATTR_2(pwm##index##_nonstop, S_IWUSR | S_IRUGO, \ 1476 SENSOR_ATTR_2(pwm##index##_nonstop, S_IWUSR | S_IRUGO, \
@@ -1482,7 +1482,7 @@ store_sf_setup(struct device *dev, struct device_attribute *attr,
1482 SENSOR_ATTR_2(fan##index##_div, S_IWUSR | S_IRUGO, \ 1482 SENSOR_ATTR_2(fan##index##_div, S_IWUSR | S_IRUGO, \
1483 show_pwm, store_pwm, PWM_DIV, index - 1), \ 1483 show_pwm, store_pwm, PWM_DIV, index - 1), \
1484 SENSOR_ATTR_2(pwm##index##_enable, S_IWUSR | S_IRUGO, \ 1484 SENSOR_ATTR_2(pwm##index##_enable, S_IWUSR | S_IRUGO, \
1485 show_pwm_enable, store_pwm_enable, NOT_USED, index - 1) 1485 show_pwm_enable, store_pwm_enable, NOT_USED, index - 1) }
1486 1486
1487#define SENSOR_ATTR_FANIN_TARGET(index) \ 1487#define SENSOR_ATTR_FANIN_TARGET(index) \
1488 SENSOR_ATTR_2(speed_cruise##index##_target, S_IWUSR | S_IRUGO, \ 1488 SENSOR_ATTR_2(speed_cruise##index##_target, S_IWUSR | S_IRUGO, \
@@ -1641,13 +1641,11 @@ static struct sensor_device_attribute_2 w83795_static[] = {
1641 SENSOR_ATTR_FANIN_TARGET(6), 1641 SENSOR_ATTR_FANIN_TARGET(6),
1642 SENSOR_ATTR_FANIN_TARGET(7), 1642 SENSOR_ATTR_FANIN_TARGET(7),
1643 SENSOR_ATTR_FANIN_TARGET(8), 1643 SENSOR_ATTR_FANIN_TARGET(8),
1644 SENSOR_ATTR_PWM(1),
1645 SENSOR_ATTR_PWM(2),
1646}; 1644};
1647 1645
1648/* all registers existed in 795g than 795adg, 1646static struct sensor_device_attribute_2 w83795_pwm[][6] = {
1649 * like PWM3 - PWM8 */ 1647 SENSOR_ATTR_PWM(1),
1650static struct sensor_device_attribute_2 w83795_left_reg[] = { 1648 SENSOR_ATTR_PWM(2),
1651 SENSOR_ATTR_PWM(3), 1649 SENSOR_ATTR_PWM(3),
1652 SENSOR_ATTR_PWM(4), 1650 SENSOR_ATTR_PWM(4),
1653 SENSOR_ATTR_PWM(5), 1651 SENSOR_ATTR_PWM(5),
@@ -1809,9 +1807,9 @@ static int w83795_handle_files(struct device *dev, int (*fn)(struct device *,
1809 return err; 1807 return err;
1810 } 1808 }
1811 1809
1812 if (data->chip_type == w83795g) { 1810 for (i = 0; i < data->has_pwm; i++) {
1813 for (i = 0; i < ARRAY_SIZE(w83795_left_reg); i++) { 1811 for (j = 0; j < ARRAY_SIZE(w83795_pwm[0]); j++) {
1814 err = fn(dev, &w83795_left_reg[i].dev_attr); 1812 err = fn(dev, &w83795_pwm[i][j].dev_attr);
1815 if (err) 1813 if (err)
1816 return err; 1814 return err;
1817 } 1815 }