Commit c024044d authored by Axel Lin's avatar Axel Lin Committed by Guenter Roeck

hwmon: (adm1021) Fix cache problem when writing temperature limits

The module test script for the adm1021 driver exposes a cache problem
when writing temperature limits. temp_min and temp_max are expected
to be stored in milli-degrees C but are stored in degrees C.
Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 1035a9e3
...@@ -185,7 +185,7 @@ static ssize_t set_temp_max(struct device *dev, ...@@ -185,7 +185,7 @@ static ssize_t set_temp_max(struct device *dev,
struct adm1021_data *data = dev_get_drvdata(dev); struct adm1021_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client; struct i2c_client *client = data->client;
long temp; long temp;
int err; int reg_val, err;
err = kstrtol(buf, 10, &temp); err = kstrtol(buf, 10, &temp);
if (err) if (err)
...@@ -193,10 +193,11 @@ static ssize_t set_temp_max(struct device *dev, ...@@ -193,10 +193,11 @@ static ssize_t set_temp_max(struct device *dev,
temp /= 1000; temp /= 1000;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp_max[index] = clamp_val(temp, -128, 127); reg_val = clamp_val(temp, -128, 127);
data->temp_max[index] = reg_val * 1000;
if (!read_only) if (!read_only)
i2c_smbus_write_byte_data(client, ADM1021_REG_TOS_W(index), i2c_smbus_write_byte_data(client, ADM1021_REG_TOS_W(index),
data->temp_max[index]); reg_val);
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
return count; return count;
...@@ -210,7 +211,7 @@ static ssize_t set_temp_min(struct device *dev, ...@@ -210,7 +211,7 @@ static ssize_t set_temp_min(struct device *dev,
struct adm1021_data *data = dev_get_drvdata(dev); struct adm1021_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client; struct i2c_client *client = data->client;
long temp; long temp;
int err; int reg_val, err;
err = kstrtol(buf, 10, &temp); err = kstrtol(buf, 10, &temp);
if (err) if (err)
...@@ -218,10 +219,11 @@ static ssize_t set_temp_min(struct device *dev, ...@@ -218,10 +219,11 @@ static ssize_t set_temp_min(struct device *dev,
temp /= 1000; temp /= 1000;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp_min[index] = clamp_val(temp, -128, 127); reg_val = clamp_val(temp, -128, 127);
data->temp_min[index] = reg_val * 1000;
if (!read_only) if (!read_only)
i2c_smbus_write_byte_data(client, ADM1021_REG_THYST_W(index), i2c_smbus_write_byte_data(client, ADM1021_REG_THYST_W(index),
data->temp_min[index]); reg_val);
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
return count; return count;
......
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