From nobody Fri Oct 3 13:32:12 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 96F492FF15D; Mon, 1 Sep 2025 08:58:35 +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=1756717118; cv=none; b=ldP4wpKI4IQ/ZPykYwvI/W9TjshJmBdRp0tVD5Hrja4x4x3eTVIyGIADk1+QGeczFbd4DOPf1BvQhcq/dN28+kR6tc9MWa+okAQtxtjyKytvZ4K4ZdBUUXoQrJ7IfR2Uf9DqHdaNgjDkXb8LihZfykYF35TYkNgLERBK2PnyKks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756717118; c=relaxed/simple; bh=6PsNSJA12rQtQ1XvZDJQx6WZz6bBmX6iNEjUN6S7Ojw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dE2nQM2DFmjRotSKdmJcy9w578qDELfgzhaDPKNcS9nR/Q2R50lnw01HpHEtqpwzOvFDDFqDDb6BRnuzuFw1grS/zNsv21abQtnqa9f/9dvm/1qwHV+ipx6DUgxIPJDoXm6pBsH9qbw9uOcS3rRiq44d7UnPHL5XRE96hfLNnaA= 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: d409ed04871111f0b29709d653e92f7d-20250901 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:d8480e87-b59a-47eb-81a8-7af7c0827343,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:76fb4ce374fb73e2a140740899724919,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: d409ed04871111f0b29709d653e92f7d-20250901 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1893902058; Mon, 01 Sep 2025 16:58:29 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 6330EE008FA8; Mon, 1 Sep 2025 16:58:28 +0800 (CST) X-ns-mid: postfix-68B56034-203598742 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 99AA3E008FAB; Mon, 1 Sep 2025 16:58:24 +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 06/12] PM / devfreq: Use scope-based cleanup helper Date: Mon, 1 Sep 2025 16:57:42 +0800 Message-Id: <20250901085748.36795-7-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/devfreq/governor_passive.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_= passive.c index 953cf9a1e9f7..a035cf44bdb8 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -80,24 +80,23 @@ static int get_target_freq_with_cpufreq(struct devfreq = *devfreq, struct devfreq_passive_data *p_data =3D (struct devfreq_passive_data *)devfreq->data; struct devfreq_cpu_data *parent_cpu_data; - struct cpufreq_policy *policy; unsigned long cpu, cpu_cur, cpu_min, cpu_max, cpu_percent; unsigned long dev_min, dev_max; unsigned long freq =3D 0; int ret =3D 0; =20 for_each_online_cpu(cpu) { - policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); + if (!policy) { ret =3D -EINVAL; continue; } =20 parent_cpu_data =3D get_parent_cpu_data(p_data, policy); - if (!parent_cpu_data) { - cpufreq_cpu_put(policy); + if (!parent_cpu_data) continue; - } =20 /* Get target freq via required opps */ cpu_cur =3D parent_cpu_data->cur_freq * HZ_PER_KHZ; @@ -106,7 +105,6 @@ static int get_target_freq_with_cpufreq(struct devfreq = *devfreq, devfreq->opp_table, &cpu_cur); if (freq) { *target_freq =3D max(freq, *target_freq); - cpufreq_cpu_put(policy); continue; } =20 @@ -121,7 +119,6 @@ static int get_target_freq_with_cpufreq(struct devfreq = *devfreq, freq =3D dev_min + mult_frac(dev_max - dev_min, cpu_percent, 100); =20 *target_freq =3D max(freq, *target_freq); - cpufreq_cpu_put(policy); } =20 return ret; @@ -256,7 +253,6 @@ static int cpufreq_passive_register_notifier(struct dev= freq *devfreq) struct device *dev =3D devfreq->dev.parent; struct opp_table *opp_table =3D NULL; struct devfreq_cpu_data *parent_cpu_data; - struct cpufreq_policy *policy; struct device *cpu_dev; unsigned int cpu; int ret; @@ -273,23 +269,23 @@ static int cpufreq_passive_register_notifier(struct d= evfreq *devfreq) } =20 for_each_possible_cpu(cpu) { - policy =3D cpufreq_cpu_get(cpu); + struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D + cpufreq_cpu_get(cpu); + if (!policy) { ret =3D -EPROBE_DEFER; goto err; } =20 parent_cpu_data =3D get_parent_cpu_data(p_data, policy); - if (parent_cpu_data) { - cpufreq_cpu_put(policy); + if (parent_cpu_data) continue; - } =20 parent_cpu_data =3D kzalloc(sizeof(*parent_cpu_data), GFP_KERNEL); if (!parent_cpu_data) { ret =3D -ENOMEM; - goto err_put_policy; + goto err; } =20 cpu_dev =3D get_cpu_device(cpu); @@ -314,7 +310,6 @@ static int cpufreq_passive_register_notifier(struct dev= freq *devfreq) parent_cpu_data->max_freq =3D policy->cpuinfo.max_freq; =20 list_add_tail(&parent_cpu_data->node, &p_data->cpu_data_list); - cpufreq_cpu_put(policy); } =20 mutex_lock(&devfreq->lock); @@ -327,8 +322,6 @@ static int cpufreq_passive_register_notifier(struct dev= freq *devfreq) =20 err_free_cpu_data: kfree(parent_cpu_data); -err_put_policy: - cpufreq_cpu_put(policy); err: =20 return ret; --=20 2.25.1