aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1026.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adm1026.c')
-rw-r--r--drivers/hwmon/adm1026.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c
index 4bf969c0a32b..6f257ce1ae07 100644
--- a/drivers/hwmon/adm1026.c
+++ b/drivers/hwmon/adm1026.c
@@ -916,7 +916,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
916 int nr = sensor_attr->index; 916 int nr = sensor_attr->index;
917 struct i2c_client *client = to_i2c_client(dev); 917 struct i2c_client *client = to_i2c_client(dev);
918 struct adm1026_data *data = i2c_get_clientdata(client); 918 struct adm1026_data *data = i2c_get_clientdata(client);
919 int val, orig_div, new_div, shift; 919 int val, orig_div, new_div;
920 920
921 val = simple_strtol(buf, NULL, 10); 921 val = simple_strtol(buf, NULL, 10);
922 new_div = DIV_TO_REG(val); 922 new_div = DIV_TO_REG(val);
@@ -928,15 +928,17 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
928 data->fan_div[nr] = DIV_FROM_REG(new_div); 928 data->fan_div[nr] = DIV_FROM_REG(new_div);
929 929
930 if (nr < 4) { /* 0 <= nr < 4 */ 930 if (nr < 4) { /* 0 <= nr < 4 */
931 shift = 2 * nr;
932 adm1026_write_value(client, ADM1026_REG_FAN_DIV_0_3, 931 adm1026_write_value(client, ADM1026_REG_FAN_DIV_0_3,
933 ((DIV_TO_REG(orig_div) & (~(0x03 << shift))) | 932 (DIV_TO_REG(data->fan_div[0]) << 0) |
934 (new_div << shift))); 933 (DIV_TO_REG(data->fan_div[1]) << 2) |
934 (DIV_TO_REG(data->fan_div[2]) << 4) |
935 (DIV_TO_REG(data->fan_div[3]) << 6));
935 } else { /* 3 < nr < 8 */ 936 } else { /* 3 < nr < 8 */
936 shift = 2 * (nr - 4);
937 adm1026_write_value(client, ADM1026_REG_FAN_DIV_4_7, 937 adm1026_write_value(client, ADM1026_REG_FAN_DIV_4_7,
938 ((DIV_TO_REG(orig_div) & (~(0x03 << (2 * shift)))) | 938 (DIV_TO_REG(data->fan_div[4]) << 0) |
939 (new_div << shift))); 939 (DIV_TO_REG(data->fan_div[5]) << 2) |
940 (DIV_TO_REG(data->fan_div[6]) << 4) |
941 (DIV_TO_REG(data->fan_div[7]) << 6));
940 } 942 }
941 943
942 if (data->fan_div[nr] != orig_div) { 944 if (data->fan_div[nr] != orig_div) {