From nobody Fri Oct 3 13:32:41 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 961652FB626; Mon, 1 Sep 2025 08:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756717102; cv=none; b=evnpKxB8oZmzR+nRKt67J4ApPCFCCnwD0H/OIi3PxCoIPgJ34J9JHVIdlw2h3RdKYcJp2qLD9u0i4GCW4iUAURKiDGR9A30X30I5G7aM4QyJrX7oxaueqOedpso8jv/ne+ClBy5QidbT7mfcJ5RLFhHfqQlV/ZFqOBPSQvf78kM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756717102; c=relaxed/simple; bh=9RC4xM37d9hqvphdVz6qwGbgCeK6UHMssRCph8J8IM4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HlJRWbZntXAKoXLwTyziWAY5/+3thRdiBlWTEGJedi9oKkZXRWiwJGags9XFPCkmLeEhns0KEJK8oV3nrWJo45vpUc/BZOj7Cm3S1TaMgubrn2Bwb4bfZR024tfNyVo6LJixoO2VC4cYp5Dd/MAlKs6Z96xxM1gd4irZNQNOqkY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: c9b1c00c871111f0b29709d653e92f7d-20250901 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:9c8abea4-fa85-4f70-8053-8228d0bd40fc,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6493067,CLOUDID:af33568b0772d3dc82685951b3e91b37,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: c9b1c00c871111f0b29709d653e92f7d-20250901 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 235447165; Mon, 01 Sep 2025 16:58:11 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 4B3D7E008FA6; Mon, 1 Sep 2025 16:58:11 +0800 (CST) X-ns-mid: postfix-68B56023-128246736 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id F1DFEE008FA7; Mon, 1 Sep 2025 16:58:06 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy Cc: Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , 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, Zihuan Zhang Subject: [PATCH v3 02/12] ACPI: processor: thermal: Use scope-based cleanup helper Date: Mon, 1 Sep 2025 16:57:38 +0800 Message-Id: <20250901085748.36795-3-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250901085748.36795-1-zhangzihuan@kylinos.cn> References: <20250901085748.36795-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- drivers/acpi/processor_thermal.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_ther= mal.c index 1219adb11ab9..3c8b57df9619 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c @@ -62,19 +62,14 @@ static int phys_package_first_cpu(int cpu) return 0; } =20 -static int cpu_has_cpufreq(unsigned int cpu) +static bool cpu_has_cpufreq(unsigned int cpu) { - struct cpufreq_policy *policy; + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(cpu); =20 if (!acpi_processor_cpufreq_init) return 0; =20 - policy =3D cpufreq_cpu_get(cpu); - if (policy) { - cpufreq_cpu_put(policy); - return 1; - } - return 0; + return !!policy; } =20 static int cpufreq_get_max_state(unsigned int cpu) @@ -95,7 +90,6 @@ static int cpufreq_get_cur_state(unsigned int cpu) =20 static int cpufreq_set_cur_state(unsigned int cpu, int state) { - struct cpufreq_policy *policy; struct acpi_processor *pr; unsigned long max_freq; int i, ret; @@ -111,6 +105,9 @@ static int cpufreq_set_cur_state(unsigned int cpu, int = state) * frequency. */ for_each_online_cpu(i) { + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(i); + if (topology_physical_package_id(i) !=3D topology_physical_package_id(cpu)) continue; @@ -120,15 +117,12 @@ static int cpufreq_set_cur_state(unsigned int cpu, in= t state) if (unlikely(!freq_qos_request_active(&pr->thermal_req))) continue; =20 - policy =3D cpufreq_cpu_get(i); if (!policy) return -EINVAL; =20 max_freq =3D (policy->cpuinfo.max_freq * (100 - reduction_step(i) * cpufreq_thermal_reduction_pctg)) / 100; =20 - cpufreq_cpu_put(policy); - ret =3D freq_qos_update_request(&pr->thermal_req, max_freq); if (ret < 0) { pr_warn("Failed to update thermal freq constraint: CPU%d (%d)\n", --=20 2.25.1