diff mbox series

[thermal:,thermal/fixes] thermal/drivers/mediatek/lvts_thermal: Return error in case of invalid efuse data

Message ID 171821234190.10875.1852169724815566067.tip-bot2@tip-bot2
State New
Headers show
Series [thermal:,thermal/fixes] thermal/drivers/mediatek/lvts_thermal: Return error in case of invalid efuse data | expand

Commit Message

thermal-bot for Julien Panis June 12, 2024, 5:12 p.m. UTC
The following commit has been merged into the thermal/fixes branch of thermal:

Commit-ID:     72cacd06e47d86d89b0e7179fbc9eb3a0f39cd93
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//72cacd06e47d86d89b0e7179fbc9eb3a0f39cd93
Author:        Julien Panis <jpanis@baylibre.com>
AuthorDate:    Tue, 04 Jun 2024 18:46:58 +02:00
Committer:     Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Wed, 12 Jun 2024 19:07:34 +02:00

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: 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>
---
 drivers/thermal/mediatek/lvts_thermal.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 82c355c..819ed01 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -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;