hwmon: (tmp401) Reset valid flag when resetting temperature history
authorGuenter Roeck <linux@roeck-us.net>
Sun, 14 Apr 2013 11:39:46 +0000 (04:39 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 21 Apr 2013 15:27:28 +0000 (08:27 -0700)
Cached data is no longer valid after resetting the temperature history.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
drivers/hwmon/tmp401.c

index 4d306b29ba716806f284c074f1ff96172977b9e8..061146288e4167eb0b929fa0162c3df07f60e739 100644 (file)
@@ -351,6 +351,8 @@ static ssize_t store_temp_crit_hyst(struct device *dev, struct device_attribute
 static ssize_t reset_temp_history(struct device *dev,
        struct device_attribute *devattr, const char *buf, size_t count)
 {
+       struct i2c_client *client = to_i2c_client(dev);
+       struct tmp401_data *data = i2c_get_clientdata(client);
        long val;
 
        if (kstrtol(buf, 10, &val))
@@ -362,8 +364,10 @@ static ssize_t reset_temp_history(struct device *dev,
                        val);
                return -EINVAL;
        }
-       i2c_smbus_write_byte_data(to_i2c_client(dev),
-                                 TMP401_TEMP_MSB_WRITE[5][0], val);
+       mutex_lock(&data->update_lock);
+       i2c_smbus_write_byte_data(client, TMP401_TEMP_MSB_WRITE[5][0], val);
+       data->valid = 0;
+       mutex_unlock(&data->update_lock);
 
        return count;
 }