thermal/drivers/mediatek: Add temperature constraints to validate read
authorAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Wed, 19 Apr 2023 06:11:46 +0000 (08:11 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 26 Apr 2023 08:38:34 +0000 (10:38 +0200)
commit47cbb0467b8b3c76faba3c2dd34b20070e6103ca
tree853e2bb354a5077153a78d69f6b8515017e493ab
parent0a677eea71fd58aa3bc805edfdbe8b0f11815c7d
thermal/drivers/mediatek: Add temperature constraints to validate read

The AUXADC thermal v1 allows reading temperature range between -20°C to
150°C and any value out of this range is invalid.

Add new definitions for MT8173_TEMP_{MIN_MAX} and a new small helper
mtk_thermal_temp_is_valid() to check if new readings are in range: if
not, we tell to the API that the reading is invalid by returning
THERMAL_TEMP_INVALID.

It was chosen to introduce the helper function because, even though this
temperature range is realistically ok for all, it comes from a downstream
kernel driver for version 1, but here we also support v2 and v3 which may
may have wider constraints.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230419061146.22246-3-angelogioacchino.delregno@collabora.com
drivers/thermal/mediatek/auxadc_thermal.c