hwmon: (w83795) Move PWM attributes to a dedidated array
authorJean Delvare <khali@linux-fr.org>
Thu, 28 Oct 2010 18:31:46 +0000 (20:31 +0200)
committerJean Delvare <khali@endymion.delvare>
Thu, 28 Oct 2010 18:31:46 +0000 (20:31 +0200)
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>
drivers/hwmon/w83795.c

index 393f1025f6c8d5c6390a31fd9408d47dfd0dc78d..76e89c7bc4654f61e9f11fa4d5e12ebbf67e7202 100644 (file)
@@ -1470,7 +1470,7 @@ store_sf_setup(struct device *dev, struct device_attribute *attr,
        SENSOR_ATTR_2(fan##index##_beep, S_IWUSR | S_IRUGO,             \
                show_alarm_beep, store_beep, BEEP_ENABLE, index + 31) }
 
-#define SENSOR_ATTR_PWM(index)                                         \
+#define SENSOR_ATTR_PWM(index) {                                       \
        SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm,          \
                store_pwm, PWM_OUTPUT, index - 1),                      \
        SENSOR_ATTR_2(pwm##index##_nonstop, S_IWUSR | S_IRUGO,          \
@@ -1482,7 +1482,7 @@ store_sf_setup(struct device *dev, struct device_attribute *attr,
        SENSOR_ATTR_2(fan##index##_div, S_IWUSR | S_IRUGO,      \
                show_pwm, store_pwm, PWM_DIV, index - 1),        \
        SENSOR_ATTR_2(pwm##index##_enable, S_IWUSR | S_IRUGO,           \
-               show_pwm_enable, store_pwm_enable, NOT_USED, index - 1)
+               show_pwm_enable, store_pwm_enable, NOT_USED, index - 1) }
 
 #define SENSOR_ATTR_FANIN_TARGET(index)                                        \
        SENSOR_ATTR_2(speed_cruise##index##_target, S_IWUSR | S_IRUGO, \
@@ -1641,13 +1641,11 @@ static struct sensor_device_attribute_2 w83795_static[] = {
        SENSOR_ATTR_FANIN_TARGET(6),
        SENSOR_ATTR_FANIN_TARGET(7),
        SENSOR_ATTR_FANIN_TARGET(8),
-       SENSOR_ATTR_PWM(1),
-       SENSOR_ATTR_PWM(2),
 };
 
-/* all registers existed in 795g than 795adg,
- * like PWM3 - PWM8 */
-static struct sensor_device_attribute_2 w83795_left_reg[] = {
+static struct sensor_device_attribute_2 w83795_pwm[][6] = {
+       SENSOR_ATTR_PWM(1),
+       SENSOR_ATTR_PWM(2),
        SENSOR_ATTR_PWM(3),
        SENSOR_ATTR_PWM(4),
        SENSOR_ATTR_PWM(5),
@@ -1809,9 +1807,9 @@ static int w83795_handle_files(struct device *dev, int (*fn)(struct device *,
                        return err;
        }
 
-       if (data->chip_type == w83795g) {
-               for (i = 0; i < ARRAY_SIZE(w83795_left_reg); i++) {
-                       err = fn(dev, &w83795_left_reg[i].dev_attr);
+       for (i = 0; i < data->has_pwm; i++) {
+               for (j = 0; j < ARRAY_SIZE(w83795_pwm[0]); j++) {
+                       err = fn(dev, &w83795_pwm[i][j].dev_attr);
                        if (err)
                                return err;
                }