[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fe21aa13-d92c-4f3e-8311-2d75468ecb4a@collabora.com>
Date: Fri, 1 Aug 2025 09:28:44 +0200
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
To: Laura Nao <laura.nao@...labora.com>, srini@...nel.org, robh@...nel.org,
krzk+dt@...nel.org, conor+dt@...nel.org, rafael@...nel.org,
daniel.lezcano@...aro.org, rui.zhang@...el.com, lukasz.luba@....com,
matthias.bgg@...il.com
Cc: wenst@...omium.org, nfraprado@...labora.com, arnd@...db.de,
colin.i.king@...il.com, u.kleine-koenig@...libre.com,
andrew-ct.chen@...iatek.com, lala.lin@...iatek.com, bchihi@...libre.com,
frank-w@...lic-files.de, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-mediatek@...ts.infradead.org,
kernel@...labora.com
Subject: Re: [PATCH v2 4/9] thermal: mediatek: lvts: Add platform ops to
support alternative conversion logic
Il 30/07/25 17:21, Laura Nao ha scritto:
> 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@...labora.com>
> ---
> 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;
You can constify this one - but then there's something else that we can do here
to waste a bit less memory.
const struct lvts_platform_ops *ops;
const struct lvts_platform_ops lvts_platform_ops_v1 = {
.lvts_raw_to_temp = lvts_raw_to_temp,
.lvts_temp_to_raw = lvts_temp_to_raw,
};
static const struct lvts_data mt8195_lvts_mcu_data = {
[..... stuff .....],
.ops = lvts_platform_ops_v1,
};
....and goes on the same for all the others.
> const u32 *conn_cmd;
> const u32 *init_cmd;
> int num_cal_offsets;
> @@ -300,6 +306,7 @@ static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
> struct lvts_ctrl *lvts_ctrl = container_of(lvts_sensor, struct lvts_ctrl,
> sensors[lvts_sensor->id]);
> const struct lvts_data *lvts_data = lvts_ctrl->lvts_data;
> + const struct lvts_platform_ops *ops = &lvts_data->ops;
...then here, and everywhere else, it would be just
const struct lvts_platform_ops *ops = lvts_data->ops;
After implementing the proposed change, exactly how I wrote them:
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
Cheers,
Angelo
Powered by blists - more mailing lists