[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250929110234.ukgwsnxyrvsimhst@vireshk-i7>
Date: Mon, 29 Sep 2025 16:32:34 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Thorsten Blum <thorsten.blum@...ux.dev>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH] rust: cpufreq: streamline find_supply_names
On 29-09-25, 11:38, Alice Ryhl wrote:
> This is a pre-existing issue, but ... this treats allocation failure
> and non-existence the same way. That sounds wrong.
What about this over the current patch:
diff --git a/drivers/cpufreq/rcpufreq_dt.rs b/drivers/cpufreq/rcpufreq_dt.rs
index 224d063c7cec..e509b46b64c7 100644
--- a/drivers/cpufreq/rcpufreq_dt.rs
+++ b/drivers/cpufreq/rcpufreq_dt.rs
@@ -26,13 +26,17 @@ fn find_supply_name_exact(dev: &Device, name: &str) -> Option<CString> {
}
/// Finds supply name for the CPU from DT.
-fn find_supply_names(dev: &Device, cpu: cpu::CpuId) -> Option<KVec<CString>> {
+fn find_supply_names(dev: &Device, cpu: cpu::CpuId) -> Result<Option<KVec<CString>>> {
// Try "cpu0" for older DTs, fallback to "cpu".
- (cpu.as_u32() == 0)
+ let name = (cpu.as_u32() == 0)
.then(|| find_supply_name_exact(dev, "cpu0"))
.flatten()
- .or_else(|| find_supply_name_exact(dev, "cpu"))
- .and_then(|name| kernel::kvec![name].ok())
+ .or_else(|| find_supply_name_exact(dev, "cpu"));
+
+ Ok(match name {
+ None => None,
+ Some(n) => Some(kernel::kvec![n]?),
+ })
}
/// Represents the cpufreq dt device.
@@ -68,7 +72,7 @@ fn init(policy: &mut cpufreq::Policy) -> Result<Self::PData> {
mask.set(cpu);
- let token = find_supply_names(dev, cpu)
+ let token = find_supply_names(dev, cpu)?
.map(|names| {
opp::Config::<Self>::new()
.set_regulator_names(names)?
--
viresh
Powered by blists - more mailing lists