lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
[an error occurred while processing this directive]
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <36bb49f6-91ac-148d-2caf-c4f52da57aed@gmail.com>
Date:   Thu, 19 Jan 2023 17:44:56 +0100
From:   Matthias Brugger <matthias.bgg@...il.com>
To:     Daniel Golle <daniel@...rotopia.org>,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>,
        linux-pm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Amit Kucheria <amitk@...nel.org>,
        Zhang Rui <rui.zhang@...el.com>,
        Rob Herring <robh+dt@...nel.org>
Cc:     Steven Liu <steven.liu@...iatek.com>,
        Henry Yen <Henry.Yen@...iatek.com>,
        Chad Monroe <chad@...roe.io>, John Crispin <john@...ozen.org>
Subject: Re: [PATCH v5 1/2] thermal/drivers/mtk: use function pointer for
 raw_to_mcelsius



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@...labora.com>
> Signed-off-by: Daniel Golle <daniel@...rotopia.org>

Reviewed-by: Matthias Brugger <matthias.bgg@...il.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,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ