From nobody Wed Sep 10 08:23:04 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 16F2D35337A; Fri, 5 Sep 2025 13:25:06 +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=1757078709; cv=none; b=EhWpgQXD4V1z+dtypBpchHSRWb3RM0xQzKQDnO6mtb/YYy2JE8wa9v/JzwbUiex1l2O0ixEAg3jq8dQ3wW0bnimCTYdG1MmB+aiQgOAGwTMkgy1PjUq8p5xbcrn+/Ah7ldEzG3+BZiNsgE/ZbqsPQ0+MXcbnfpNo8XOx77TI83o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757078709; c=relaxed/simple; bh=vpnK+wgxPDyyGBiNRyOVaIAlcPF3ONZ70dk/Vdt+kro=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rody1JRDeRk/msd/i2NYZIr/PMFj21jCY4VB4ZexsxDKt4SvtViJqNi5xDmflG6Qd5ZE1lnfIioA/XN1AWUXYQJwUBwO+rh79HB+yn4EwfF/o+b2Z4LceMVTaIcERqN7stvOw1SkWlAf6Ltbsi3ZW1nRDakq61IFL6Ve2iZkYQs= 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: b8db92f68a5b11f0b29709d653e92f7d-20250905 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:646670e5-e5c7-40b1-b28a-3ee5e8c5af3a,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6493067,CLOUDID:f6a8c23197cabdb3bff5558c69d77a16,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: b8db92f68a5b11f0b29709d653e92f7d-20250905 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 530252194; Fri, 05 Sep 2025 21:24:59 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 4D67FE008FA3; Fri, 5 Sep 2025 21:24:59 +0800 (CST) X-ns-mid: postfix-68BAE4AB-1181537 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 70239E008FA7; Fri, 5 Sep 2025 21:24:55 +0800 (CST) From: Zihuan Zhang To: "Rafael J . wysocki" , Viresh Kumar , Jonathan Cameron , 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 v5 6/6] PM: EM: Use scope-based cleanup helper Date: Fri, 5 Sep 2025 21:24:13 +0800 Message-Id: <20250905132413.1376220-7-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250905132413.1376220-1-zhangzihuan@kylinos.cn> References: <20250905132413.1376220-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 --- kernel/power/energy_model.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index ea7995a25780..5ec63b3e7d85 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -451,7 +451,6 @@ static void em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *t= able) { struct em_perf_domain *pd =3D dev->em_pd; - struct cpufreq_policy *policy; int found =3D 0; int i, cpu; =20 @@ -465,7 +464,7 @@ em_cpufreq_update_efficiencies(struct device *dev, stru= ct em_perf_state *table) return; } =20 - policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_= get(cpu); if (!policy) { dev_warn(dev, "EM: Access to CPUFreq policy failed\n"); return; @@ -479,8 +478,6 @@ em_cpufreq_update_efficiencies(struct device *dev, stru= ct em_perf_state *table) found++; } =20 - cpufreq_cpu_put(policy); - if (!found) return; =20 @@ -787,21 +784,19 @@ static void em_check_capacity_update(void) =20 /* Check if CPUs capacity has changed than update EM */ for_each_possible_cpu(cpu) { - struct cpufreq_policy *policy; struct em_perf_domain *pd; struct device *dev; =20 if (cpumask_test_cpu(cpu, cpu_done_mask)) continue; =20 - policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu= _get(cpu); if (!policy) { pr_debug("Accessing cpu%d policy failed\n", cpu); schedule_delayed_work(&em_update_work, msecs_to_jiffies(1000)); break; } - cpufreq_cpu_put(policy); =20 dev =3D get_cpu_device(cpu); pd =3D em_pd_get(dev); --=20 2.25.1