[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250905110551.00006588@huawei.com>
Date: Fri, 5 Sep 2025 11:05:51 +0100
From: Jonathan Cameron <jonathan.cameron@...wei.com>
To: Zihuan Zhang <zhangzihuan@...inos.cn>
CC: "Rafael J . wysocki" <rafael@...nel.org>, Viresh Kumar
<viresh.kumar@...aro.org>, Catalin Marinas <catalin.marinas@....com>, "Will
Deacon" <will@...nel.org>, Borislav Petkov <bp@...en8.de>, Dave Hansen
<dave.hansen@...ux.intel.com>, Srinivas Pandruvada
<srinivas.pandruvada@...ux.intel.com>, Michael Ellerman <mpe@...erman.id.au>,
Krzysztof Kozlowski <krzk@...nel.org>, Alim Akhtar <alim.akhtar@...sung.com>,
Thierry Reding <thierry.reding@...il.com>, MyungJoo Ham
<myungjoo.ham@...sung.com>, Kyungmin Park <kyungmin.park@...sung.com>,
Chanwoo Choi <cw00.choi@...sung.com>, "Jani Nikula"
<jani.nikula@...ux.intel.com>, Rodrigo Vivi <rodrigo.vivi@...el.com>, Tvrtko
Ursulin <tursulin@...ulin.net>, "David Airlie" <airlied@...il.com>, Simona
Vetter <simona@...ll.ch>, Daniel Lezcano <daniel.lezcano@...nel.org>, Sascha
Hauer <s.hauer@...gutronix.de>, "Shawn Guo" <shawnguo@...nel.org>, Eduardo
Valentin <edubezval@...il.com>, Keerthy <j-keerthy@...com>, Ben Horgan
<ben.horgan@....com>, zhenglifeng <zhenglifeng1@...wei.com>, Zhang Rui
<rui.zhang@...el.com>, Len Brown <lenb@...nel.org>, Lukasz Luba
<lukasz.luba@....com>, "Pengutronix Kernel Team" <kernel@...gutronix.de>,
Beata Michalska <beata.michalska@....com>, Fabio Estevam
<festevam@...il.com>, Pavel Machek <pavel@...nel.org>, "Sumit Gupta"
<sumitg@...dia.com>, Prasanna Kumar T S M <ptsm@...ux.microsoft.com>, Sudeep
Holla <sudeep.holla@....com>, Yicong Yang <yangyicong@...ilicon.com>,
<linux-pm@...r.kernel.org>, <linux-acpi@...r.kernel.org>,
<linuxppc-dev@...ts.ozlabs.org>, <linux-arm-kernel@...ts.infradead.org>,
<intel-gfx@...ts.freedesktop.org>, <dri-devel@...ts.freedesktop.org>,
<imx@...ts.linux.dev>, <linux-omap@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 08/10] thermal: imx: Use scope-based cleanup helper
On Wed, 3 Sep 2025 21:17:31 +0800
Zihuan Zhang <zhangzihuan@...inos.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@...inos.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
Powered by blists - more mailing lists