Re: [PATCH v2 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic

From: Fei Shao
Date: Thu Jul 31 2025 - 00:04:03 EST


On Wed, Jul 30, 2025 at 11:35 PM Laura Nao <laura.nao@xxxxxxxxxxxxx> wrote:
>
> Introduce lvts_platform_ops struct to support SoC-specific versions of
> lvts_raw_to_temp() and lvts_temp_to_raw() conversion functions.
>
> This is in preparation for supporting SoCs like MT8196/MT6991, which
> require a different lvts_temp_to_raw() implementation.
>
> Signed-off-by: Laura Nao <laura.nao@xxxxxxxxxxxxx>
> ---
> drivers/thermal/mediatek/lvts_thermal.c | 46 +++++++++++++++++++++++--
> 1 file changed, 43 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> index 8398af657ba2..6e4a35ecaf34 100644
> --- a/drivers/thermal/mediatek/lvts_thermal.c
> +++ b/drivers/thermal/mediatek/lvts_thermal.c
> @@ -125,8 +125,14 @@ struct lvts_ctrl_data {
> continue; \
> else
>
> +struct lvts_platform_ops {
> + int (*lvts_raw_to_temp)(u32 raw_temp, int temp_factor);
> + u32 (*lvts_temp_to_raw)(int temperature, int temp_factor);
> +};
> +
> struct lvts_data {
> const struct lvts_ctrl_data *lvts_ctrl;
> + struct lvts_platform_ops ops;

nit: I think this can also be a const struct, since ops are all
initialized in the platform data and never change.

Anyway, the changes look good IMO, so
Reviewed-by: Fei Shao <fshao@xxxxxxxxxxxx>

> const u32 *conn_cmd;
> const u32 *init_cmd;
> int num_cal_offsets;

[...]