Skip to contentSkip to conversation

hwmon: (tmp401) Reset valid flag when resetting temperature history

PATCH In review Guenter Roeck 2 participants 3 messages Apr 14, 2013 – Apr 20, 2013 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 2/4 hwmon: (tmp401) Reset valid flag when resetting temperature history

Cached data is no longer valid after resetting the temperature history.

---
 drivers/hwmon/tmp401.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hwmon/tmp401.c +6 -2
index a92746f..2f581a5 100644
@@ -353,6 +353,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))
@@ -364,8 +366,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;
 }
Signature · 7 lines
1.7.9.7


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Acked-by on v1 2/4
#1 lore raw
Quoted 23 lines · Guenter Roeck

Cached data is no longer valid after resetting the temperature history.

---
 drivers/hwmon/tmp401.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hwmon/tmp401.c +2 -0
index a92746f..2f581a5 100644
@@ -353,6 +353,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))
@@ -364,8 +366,10 @@ static ssize_t reset_temp_history(struct device *dev,
 			val);
 		return -EINVAL;

drivers/hwmon/tmp401.c static ssize_t reset_temp_history(struct device *dev, · line 375

Quoted 10 lines
drivers/hwmon/tmp401.c +4 -2
 	}
-	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;
 }
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author maintainer
#2 lore raw

PATCH 2/4 hwmon: (tmp401) Reset valid flag when resetting temperature history

In reply to Guenter Roeck

Cached data is no longer valid after resetting the temperature history.

---
 drivers/hwmon/tmp401.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hwmon/tmp401.c +6 -2
index 4d306b2..0611462 100644
@@ -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;
 }
Signature · 7 lines
1.7.9.7


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors