Skip to content

Commit

Permalink
hwmon: (adm1021) Fix cache problem when writing temperature limits
Browse files Browse the repository at this point in the history
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: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
AxelLin authored and groeck committed Jul 3, 2014
1 parent 1035a9e commit c024044
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions drivers/hwmon/adm1021.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,19 @@ static ssize_t set_temp_max(struct device *dev,
struct adm1021_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
long temp;
int err;
int reg_val, err;

err = kstrtol(buf, 10, &temp);
if (err)
return err;
temp /= 1000;

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)
i2c_smbus_write_byte_data(client, ADM1021_REG_TOS_W(index),
data->temp_max[index]);
reg_val);
mutex_unlock(&data->update_lock);

return count;
Expand All @@ -210,18 +211,19 @@ static ssize_t set_temp_min(struct device *dev,
struct adm1021_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
long temp;
int err;
int reg_val, err;

err = kstrtol(buf, 10, &temp);
if (err)
return err;
temp /= 1000;

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)
i2c_smbus_write_byte_data(client, ADM1021_REG_THYST_W(index),
data->temp_min[index]);
reg_val);
mutex_unlock(&data->update_lock);

return count;
Expand Down

0 comments on commit c024044

Please sign in to comment.