public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Jonathan Cameron <jonathan.cameron@huawei•com>
To: Zihuan Zhang <zhangzihuan@kylinos•cn>
Cc: "Rafael J . wysocki" <rafael@kernel•org>,
	Viresh Kumar <viresh.kumar@linaro•org>,
	Catalin Marinas <catalin.marinas@arm•com>,
	"Will Deacon" <will@kernel•org>, Borislav Petkov <bp@alien8•de>,
	Dave Hansen <dave.hansen@linux•intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux•intel.com>,
	Michael Ellerman <mpe@ellerman•id.au>,
	Krzysztof Kozlowski <krzk@kernel•org>,
	Alim Akhtar <alim.akhtar@samsung•com>,
	Thierry Reding <thierry.reding@gmail•com>,
	MyungJoo Ham <myungjoo.ham@samsung•com>,
	Kyungmin Park <kyungmin.park@samsung•com>,
	Chanwoo Choi <cw00.choi@samsung•com>,
	"Jani Nikula" <jani.nikula@linux•intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel•com>,
	Tvrtko Ursulin <tursulin@ursulin•net>,
	"David Airlie" <airlied@gmail•com>,
	Simona Vetter <simona@ffwll•ch>,
	Daniel Lezcano <daniel.lezcano@kernel•org>,
	Sascha Hauer <s.hauer@pengutronix•de>,
	"Shawn Guo" <shawnguo@kernel•org>,
	Eduardo Valentin <edubezval@gmail•com>,
	Keerthy <j-keerthy@ti•com>, Ben Horgan <ben.horgan@arm•com>,
	zhenglifeng <zhenglifeng1@huawei•com>,
	Zhang Rui <rui.zhang@intel•com>, Len Brown <lenb@kernel•org>,
	Lukasz Luba <lukasz.luba@arm•com>,
	"Pengutronix Kernel Team" <kernel@pengutronix•de>,
	Beata Michalska <beata.michalska@arm•com>,
	Fabio Estevam <festevam@gmail•com>,
	Pavel Machek <pavel@kernel•org>,
	"Sumit Gupta" <sumitg@nvidia•com>,
	Prasanna Kumar T S M <ptsm@linux•microsoft.com>,
	Sudeep Holla <sudeep.holla@arm•com>,
	Yicong Yang <yangyicong@hisilicon•com>,
	<linux-pm@vger•kernel.org>, <linux-acpi@vger•kernel.org>,
	<linuxppc-dev@lists•ozlabs.org>,
	<linux-arm-kernel@lists•infradead.org>,
	<intel-gfx@lists•freedesktop.org>,
	<dri-devel@lists•freedesktop.org>, <imx@lists•linux.dev>,
	<linux-omap@vger•kernel.org>, <linux-kernel@vger•kernel.org>
Subject: Re: [PATCH v4 08/10] thermal: imx: Use scope-based cleanup helper
Date: Fri, 5 Sep 2025 11:05:51 +0100	[thread overview]
Message-ID: <20250905110551.00006588@huawei.com> (raw)
In-Reply-To: <20250903131733.57637-9-zhangzihuan@kylinos.cn>

On Wed,  3 Sep 2025 21:17:31 +0800
Zihuan Zhang <zhangzihuan@kylinos•cn> wrote:

> Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy)
> annotation for policy references. This reduces the risk of reference
> counting mistakes and aligns the code with the latest kernel style.
> 
> No functional change intended.
> 
> Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos•cn>

This radically changes the lifetime of the reference to policy.
If that is valid, then I'd expect a lot more description of why!

> ---
>  drivers/thermal/imx_thermal.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index 38c993d1bcb3..cd1d9d419275 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -201,7 +201,6 @@ static struct thermal_soc_data thermal_imx7d_data = {
>  
>  struct imx_thermal_data {
>  	struct device *dev;
> -	struct cpufreq_policy *policy;
>  	struct thermal_zone_device *tz;
>  	struct thermal_cooling_device *cdev;
>  	struct regmap *tempmon;
> @@ -541,22 +540,20 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
>  static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
>  {
>  	struct device_node *np;
> +	struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(0);
>  	int ret = 0;
>  
> -	data->policy = cpufreq_cpu_get(0);
> -	if (!data->policy) {
> +	if (!policy) {
>  		pr_debug("%s: CPUFreq policy not found\n", __func__);
>  		return -EPROBE_DEFER;
>  	}
>  
> -	np = of_get_cpu_node(data->policy->cpu, NULL);
> +	np = of_get_cpu_node(policy->cpu, NULL);
>  
>  	if (!np || !of_property_present(np, "#cooling-cells")) {
> -		data->cdev = cpufreq_cooling_register(data->policy);
> -		if (IS_ERR(data->cdev)) {
> +		data->cdev = cpufreq_cooling_register(policy);
> +		if (IS_ERR(data->cdev))
>  			ret = PTR_ERR(data->cdev);
> -			cpufreq_cpu_put(data->policy);
> -		}
>  	}
>  
>  	of_node_put(np);
> @@ -567,7 +564,6 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
>  static void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data *data)
>  {
>  	cpufreq_cooling_unregister(data->cdev);
> -	cpufreq_cpu_put(data->policy);
>  }
>  
>  #else



  reply	other threads:[~2025-09-05 10:06 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-03 13:17 [PATCH v4 00/10] cpufreq: use __free() for all cpufreq_cpu_get() references Zihuan Zhang
2025-09-03 13:17 ` [PATCH v4 01/10] arm64: topology: Use scope-based cleanup helper Zihuan Zhang
2025-09-05  9:38   ` Jonathan Cameron
2025-09-03 13:17 ` [PATCH v4 02/10] ACPI: processor: thermal: " Zihuan Zhang
2025-09-03 13:23   ` Rafael J. Wysocki
2025-09-05  9:45     ` Jonathan Cameron
2025-09-03 13:17 ` [PATCH v4 03/10] cpufreq: intel_pstate: " Zihuan Zhang
2025-09-05  9:47   ` Jonathan Cameron
2025-09-05  9:48   ` Rafael J. Wysocki
2025-09-03 13:17 ` [PATCH v4 04/10] cpufreq: powernv: " Zihuan Zhang
2025-09-05  9:49   ` Jonathan Cameron
2025-09-03 13:17 ` [PATCH v4 05/10] PM / devfreq: " Zihuan Zhang
2025-09-05 10:01   ` Jonathan Cameron
2025-09-03 13:17 ` [PATCH v4 06/10] drm/i915: " Zihuan Zhang
2025-09-05 10:02   ` Jonathan Cameron
2025-09-03 13:17 ` [PATCH v4 07/10] powercap: dtpm_cpu: " Zihuan Zhang
2025-09-03 13:45   ` Rafael J. Wysocki
2025-09-04 10:37     ` Zihuan Zhang
2025-09-04 10:55       ` Krzysztof Kozlowski
2025-09-04 13:17       ` Rafael J. Wysocki
2025-09-05  7:44         ` Zihuan Zhang
2025-09-03 13:17 ` [PATCH v4 08/10] thermal: imx: " Zihuan Zhang
2025-09-05 10:05   ` Jonathan Cameron [this message]
2025-09-05 10:21     ` Zihuan Zhang
2025-09-03 13:17 ` [PATCH v4 09/10] thermal/drivers/ti-soc-thermal: " Zihuan Zhang
2025-09-05  6:57   ` Andreas Kemnade
2025-09-05  7:02     ` Krzysztof Kozlowski
2025-09-05  7:54     ` Zihuan Zhang
2025-09-03 13:17 ` [PATCH v4 10/10] PM: EM: " Zihuan Zhang
2025-09-03 13:21   ` Krzysztof Kozlowski
2025-09-03 13:41     ` Rafael J. Wysocki
2025-09-03 13:43       ` Krzysztof Kozlowski
2025-09-04  7:56         ` Zihuan Zhang

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=20250905110551.00006588@huawei.com \
    --to=jonathan.cameron@huawei$(echo .)com \
    --cc=airlied@gmail$(echo .)com \
    --cc=alim.akhtar@samsung$(echo .)com \
    --cc=beata.michalska@arm$(echo .)com \
    --cc=ben.horgan@arm$(echo .)com \
    --cc=bp@alien8$(echo .)de \
    --cc=catalin.marinas@arm$(echo .)com \
    --cc=cw00.choi@samsung$(echo .)com \
    --cc=daniel.lezcano@kernel$(echo .)org \
    --cc=dave.hansen@linux$(echo .)intel.com \
    --cc=dri-devel@lists$(echo .)freedesktop.org \
    --cc=edubezval@gmail$(echo .)com \
    --cc=festevam@gmail$(echo .)com \
    --cc=imx@lists$(echo .)linux.dev \
    --cc=intel-gfx@lists$(echo .)freedesktop.org \
    --cc=j-keerthy@ti$(echo .)com \
    --cc=jani.nikula@linux$(echo .)intel.com \
    --cc=kernel@pengutronix$(echo .)de \
    --cc=krzk@kernel$(echo .)org \
    --cc=kyungmin.park@samsung$(echo .)com \
    --cc=lenb@kernel$(echo .)org \
    --cc=linux-acpi@vger$(echo .)kernel.org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-omap@vger$(echo .)kernel.org \
    --cc=linux-pm@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=lukasz.luba@arm$(echo .)com \
    --cc=mpe@ellerman$(echo .)id.au \
    --cc=myungjoo.ham@samsung$(echo .)com \
    --cc=pavel@kernel$(echo .)org \
    --cc=ptsm@linux$(echo .)microsoft.com \
    --cc=rafael@kernel$(echo .)org \
    --cc=rodrigo.vivi@intel$(echo .)com \
    --cc=rui.zhang@intel$(echo .)com \
    --cc=s.hauer@pengutronix$(echo .)de \
    --cc=shawnguo@kernel$(echo .)org \
    --cc=simona@ffwll$(echo .)ch \
    --cc=srinivas.pandruvada@linux$(echo .)intel.com \
    --cc=sudeep.holla@arm$(echo .)com \
    --cc=sumitg@nvidia$(echo .)com \
    --cc=thierry.reding@gmail$(echo .)com \
    --cc=tursulin@ursulin$(echo .)net \
    --cc=viresh.kumar@linaro$(echo .)org \
    --cc=will@kernel$(echo .)org \
    --cc=yangyicong@hisilicon$(echo .)com \
    --cc=zhangzihuan@kylinos$(echo .)cn \
    --cc=zhenglifeng1@huawei$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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