Commit 72cacd06 authored by Julien Panis's avatar Julien Panis Committed by Daniel Lezcano

thermal/drivers/mediatek/lvts_thermal: Return error in case of invalid efuse data

This patch prevents from registering thermal entries and letting the
driver misbehave if efuse data is invalid. A device is not properly
calibrated if the golden temperature is zero.

Fixes: f5f633b1 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
Signed-off-by: default avatarJulien Panis <jpanis@baylibre.com>
Reviewed-by: default avatarNicolas Pitre <npitre@baylibre.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20240604-mtk-thermal-calib-check-v2-1-8f258254051d@baylibre.comSigned-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent d9fef76e
......@@ -769,7 +769,11 @@ static int lvts_golden_temp_init(struct device *dev, u8 *calib,
*/
gt = (((u32 *)calib)[0] >> lvts_data->gt_calib_bit_offset) & 0xff;
if (gt && gt < LVTS_GOLDEN_TEMP_MAX)
/* A zero value for gt means that device has invalid efuse data */
if (!gt)
return -ENODATA;
if (gt < LVTS_GOLDEN_TEMP_MAX)
golden_temp = gt;
golden_temp_offset = golden_temp * 500 + lvts_data->temp_offset;
......
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