summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorJulien Panis <jpanis@baylibre.com>2024-06-04 19:46:58 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-06-27 14:49:09 +0300
commit90d29da11445decf64a2f7a4a08d4394027ecf5e (patch)
tree8347182c02a2fc5c174b80631d013800c06ae8e7 /drivers/thermal
parent47a0fe77b6c89628499ea0978b1d302834c66b59 (diff)
downloadlinux-90d29da11445decf64a2f7a4a08d4394027ecf5e.tar.xz
thermal/drivers/mediatek/lvts_thermal: Return error in case of invalid efuse data
[ Upstream commit 72cacd06e47d86d89b0e7179fbc9eb3a0f39cd93 ] 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: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver") Signed-off-by: Julien Panis <jpanis@baylibre.com> Reviewed-by: Nicolas Pitre <npitre@baylibre.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20240604-mtk-thermal-calib-check-v2-1-8f258254051d@baylibre.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/mediatek/lvts_thermal.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index a4e56017dda3..666f440b6663 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -700,7 +700,11 @@ static int lvts_golden_temp_init(struct device *dev, u32 *value)
gt = (*value) >> 24;
- 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;
coeff_b = golden_temp * 500 + LVTS_COEFF_B;