Re: [PATCH v4 2/2] thermal: mediatek: add support for MT7986 and MT7981

From: AngeloGioacchino Del Regno
Date: Wed Jan 18 2023 - 08:28:29 EST


Il 18/01/23 04:55, Daniel Golle ha scritto:
Add support for V3 generation thermal found in MT7986 and MT7981 SoCs.
Brings code to assign values from efuse as well as new function to
convert raw temperature to millidegree celsius, as found in MediaTek's
SDK sources (but cleaned up and de-duplicated)

[1]: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/baf36c7eef477aae1f8f2653b6c29e2caf48475b
Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
---
drivers/thermal/mtk_thermal.c | 137 ++++++++++++++++++++++++++++++++--
1 file changed, 132 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 992750ee09e62..171f485a809bb 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c

..snip..

.data = (void *)&mt8183_thermal_data,
@@ -1068,15 +1186,24 @@ static int mtk_thermal_probe(struct platform_device *pdev)
goto err_disable_clk_auxadc;
}
- if (mt->conf->version == MTK_THERMAL_V2) {
+ if (mt->conf->version != MTK_THERMAL_V1) {
mtk_thermal_turn_on_buffer(apmixed_base);
mtk_thermal_release_periodic_ts(mt, auxadc_base);
}
- if (mt->conf->version == MTK_THERMAL_V1)
+ switch (mt->conf->version) {
+ case MTK_THERMAL_V1:
mt->raw_to_mcelsius = raw_to_mcelsius_v1;
- else
+ break;
+ case MTK_THERMAL_V2:
mt->raw_to_mcelsius = raw_to_mcelsius_v2;
+ break;
+ case MTK_THERMAL_V3:
+ mt->raw_to_mcelsius = raw_to_mcelsius_v3;
+ break;
+ default:
+ break;
+ }

Either directly use a switch in your commit [1/2] or follow `else if` here.

I would prefer if you changed your first commit to use a switch, but I don't
really have strong opinions, which is why I gave you a Reviewed-by tag on
[1/2].

Your choice - but please don't "change the game" all of a sudden in a commit
whose purpose is to add support for a new version of MTK_THERMAL. :-)

Cheers,
Angelo