Skip to contentSkip to conversation

hwmon: (lm90) Fix max6658 sporadic wrong temperature reading

PATCH Guenter Roeck 1 participant 1 message Jun 20, 2019 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

Hi,

Quoted 16 lines · Boyang Yu

max6658 may report unrealistically high temperature during the driver initialization, for which, its overtemp alarm pin also gets asserted. For certain devices implementing overtemp protection based on that pin, it may further trigger a reset to the device. By reproducing the problem, the wrong reading is found to be coincident with changing the conversion rate.

To mitigate this issue, set the stop bit before changing the conversion rate and unset it thereafter. After such change, the wrong reading is not reproduced. As the issue is only found on max6658, apply this change only to the max6657 kind.

---
 drivers/hwmon/lm90.c | 54 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 50 insertions(+), 4 deletions(-)

[ ... ]

Quoted 5 lines

/*
* Set conversion rate.
* client->update_lock must be held when calling this function (unless we are

Review static int lm90_set_convrate(struct i2c_client *client, struct lm90_data *data, · line 623

Quoted 9 lines
(quoted diff) +5 -1
@@ -587,7 +616,11 @@ static int lm90_set_convrate(struct i2c_client *client, struct lm90_data *data,
 		if (interval >= update_interval * 3 / 4)
 			break;
 
-	err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, i);
+	if (data->kind == max6657)
+		err = max6657_write_convrate(client, i);
+	else
+		err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, i);
+

Please name the new function lm90_write_convrate, call it unconditionally, and check if the chip is affected in the function. Also, please implement the check with a feature flag - it is quite unlikely that only max6658 is affected, and we'll want an easy method to add support for other chips.

Thanks,
Guenter