Commit 2ca2fcd1 authored by Jim Cromie's avatar Jim Cromie Committed by Mark M. Hoffman

hwmon: (w83627hf) push nr+1 offset into *_REG_FAN macros and simplify

patch changes 2 macros to incorporate the +1, and drops the +1 from all the
callers.  This also allows a 'reroll' of an expanded loop, and adjusting
indexes and loop limits on another.
Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
Acked-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarMark M. Hoffman <mhoffman@lightlink.com>
parent df48ed80
...@@ -170,8 +170,9 @@ superio_exit(void) ...@@ -170,8 +170,9 @@ superio_exit(void)
#define W83781D_REG_IN(nr) ((nr < 7) ? (0x20 + (nr)) : \ #define W83781D_REG_IN(nr) ((nr < 7) ? (0x20 + (nr)) : \
(0x550 + (nr) - 7)) (0x550 + (nr) - 7))
#define W83781D_REG_FAN_MIN(nr) (0x3a + (nr)) /* nr:0-2 for fans:1-3 */
#define W83781D_REG_FAN(nr) (0x27 + (nr)) #define W83627HF_REG_FAN_MIN(nr) (0x3b + (nr))
#define W83627HF_REG_FAN(nr) (0x28 + (nr))
#define W83627HF_REG_TEMP2_CONFIG 0x152 #define W83627HF_REG_TEMP2_CONFIG 0x152
#define W83627HF_REG_TEMP3_CONFIG 0x252 #define W83627HF_REG_TEMP3_CONFIG 0x252
...@@ -582,7 +583,7 @@ store_fan_min(struct device *dev, struct device_attribute *devattr, ...@@ -582,7 +583,7 @@ store_fan_min(struct device *dev, struct device_attribute *devattr,
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
w83627hf_write_value(data, W83781D_REG_FAN_MIN(nr+1), w83627hf_write_value(data, W83627HF_REG_FAN_MIN(nr),
data->fan_min[nr]); data->fan_min[nr]);
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
...@@ -814,7 +815,7 @@ store_fan_div(struct device *dev, struct device_attribute *devattr, ...@@ -814,7 +815,7 @@ store_fan_div(struct device *dev, struct device_attribute *devattr,
/* Restore fan_min */ /* Restore fan_min */
data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
w83627hf_write_value(data, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); w83627hf_write_value(data, W83627HF_REG_FAN_MIN(nr), data->fan_min[nr]);
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
return count; return count;
...@@ -1140,7 +1141,7 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) ...@@ -1140,7 +1141,7 @@ static int __devinit w83627hf_probe(struct platform_device *pdev)
struct w83627hf_sio_data *sio_data = dev->platform_data; struct w83627hf_sio_data *sio_data = dev->platform_data;
struct w83627hf_data *data; struct w83627hf_data *data;
struct resource *res; struct resource *res;
int err; int err, i;
static const char *names[] = { static const char *names[] = {
"w83627hf", "w83627hf",
...@@ -1174,9 +1175,9 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) ...@@ -1174,9 +1175,9 @@ static int __devinit w83627hf_probe(struct platform_device *pdev)
w83627hf_init_device(pdev); w83627hf_init_device(pdev);
/* A few vars need to be filled upon startup */ /* A few vars need to be filled upon startup */
data->fan_min[0] = w83627hf_read_value(data, W83781D_REG_FAN_MIN(1)); for (i = 0; i <= 2; i++)
data->fan_min[1] = w83627hf_read_value(data, W83781D_REG_FAN_MIN(2)); data->fan_min[i] = w83627hf_read_value(
data->fan_min[2] = w83627hf_read_value(data, W83781D_REG_FAN_MIN(3)); data, W83627HF_REG_FAN_MIN(i));
w83627hf_update_fan_div(data); w83627hf_update_fan_div(data);
/* Register common device attributes */ /* Register common device attributes */
...@@ -1554,12 +1555,12 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) ...@@ -1554,12 +1555,12 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
w83627hf_read_value(data, w83627hf_read_value(data,
W83781D_REG_IN_MAX(i)); W83781D_REG_IN_MAX(i));
} }
for (i = 1; i <= 3; i++) { for (i = 0; i <= 2; i++) {
data->fan[i - 1] = data->fan[i] =
w83627hf_read_value(data, W83781D_REG_FAN(i)); w83627hf_read_value(data, W83627HF_REG_FAN(i));
data->fan_min[i - 1] = data->fan_min[i] =
w83627hf_read_value(data, w83627hf_read_value(data,
W83781D_REG_FAN_MIN(i)); W83627HF_REG_FAN_MIN(i));
} }
for (i = 0; i <= 2; i++) { for (i = 0; i <= 2; i++) {
u8 tmp = w83627hf_read_value(data, u8 tmp = w83627hf_read_value(data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment