mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthias Brugger <matthias.bgg@gmail.com>
To: Daniel Golle <daniel@makrotopia.org>,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>,
	linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
	Rob Herring <robh+dt@kernel.org>
Cc: Steven Liu <steven.liu@mediatek.com>,
	Henry Yen <Henry.Yen@mediatek.com>, Chad Monroe <chad@monroe.io>,
	John Crispin <john@phrozen.org>
Subject: Re: [PATCH v5 1/2] thermal/drivers/mtk: use function pointer for raw_to_mcelsius
Date: Thu, 19 Jan 2023 17:44:56 +0100	[thread overview]
Message-ID: <36bb49f6-91ac-148d-2caf-c4f52da57aed@gmail.com> (raw)
In-Reply-To: <69c17529e8418da3eec703dde31e1b01e5b0f7e8.1674055882.git.daniel@makrotopia.org>



On 18/01/2023 16:40, Daniel Golle wrote:
> Instead of having if-else logic selecting either raw_to_mcelsius_v1 or
> raw_to_mcelsius_v2 in mtk_thermal_bank_temperature introduce a function
> pointer raw_to_mcelsius to struct mtk_thermal which is initialized in the
> probe function.
> 
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> ---
>   drivers/thermal/mtk_thermal.c | 17 ++++++++++-------
>   1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
> index 0084b76493d9a..992750ee09e62 100644
> --- a/drivers/thermal/mtk_thermal.c
> +++ b/drivers/thermal/mtk_thermal.c
> @@ -292,6 +292,8 @@ struct mtk_thermal {
>   
>   	const struct mtk_thermal_data *conf;
>   	struct mtk_thermal_bank banks[MAX_NUM_ZONES];
> +
> +	int (*raw_to_mcelsius)(struct mtk_thermal *mt, int sensno, s32 raw);
>   };
>   
>   /* MT8183 thermal sensor data */
> @@ -656,13 +658,9 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)
>   	for (i = 0; i < conf->bank_data[bank->id].num_sensors; i++) {
>   		raw = readl(mt->thermal_base + conf->msr[i]);
>   
> -		if (mt->conf->version == MTK_THERMAL_V1) {
> -			temp = raw_to_mcelsius_v1(
> -				mt, conf->bank_data[bank->id].sensors[i], raw);
> -		} else {
> -			temp = raw_to_mcelsius_v2(
> -				mt, conf->bank_data[bank->id].sensors[i], raw);
> -		}
> +		temp = mt->raw_to_mcelsius(
> +			mt, conf->bank_data[bank->id].sensors[i], raw);
> +
>   
>   		/*
>   		 * The first read of a sensor often contains very high bogus
> @@ -1075,6 +1073,11 @@ static int mtk_thermal_probe(struct platform_device *pdev)
>   		mtk_thermal_release_periodic_ts(mt, auxadc_base);
>   	}
>   
> +	if (mt->conf->version == MTK_THERMAL_V1)
> +		mt->raw_to_mcelsius = raw_to_mcelsius_v1;
> +	else
> +		mt->raw_to_mcelsius = raw_to_mcelsius_v2;
> +
>   	for (ctrl_id = 0; ctrl_id < mt->conf->num_controller ; ctrl_id++)
>   		for (i = 0; i < mt->conf->num_banks; i++)
>   			mtk_thermal_init_bank(mt, i, apmixed_phys_base,

  reply	other threads:[~2023-01-19 16:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18 15:40 [PATCH v5 0/2] thermal: mediatek: add support for MT7986 and MT7981 Daniel Golle
2023-01-18 15:40 ` [PATCH v5 1/2] thermal/drivers/mtk: use function pointer for raw_to_mcelsius Daniel Golle
2023-01-19 16:44   ` Matthias Brugger [this message]
2023-01-18 15:40 ` [PATCH v5 2/2] thermal: mediatek: add support for MT7986 and MT7981 Daniel Golle
2023-01-20  8:53   ` AngeloGioacchino Del Regno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36bb49f6-91ac-148d-2caf-c4f52da57aed@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=Henry.Yen@mediatek.com \
    --cc=amitk@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chad@monroe.io \
    --cc=daniel.lezcano@linaro.org \
    --cc=daniel@makrotopia.org \
    --cc=john@phrozen.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=steven.liu@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome