lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aElxv3hRIc6Z_7jg@cassiopeiae>
Date: Wed, 11 Jun 2025 14:08:31 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Remo Senekowitsch <remo@...nzli.dev>,
	Viresh Kumar <viresh.kumar@...aro.org>
Cc: Rob Herring <robh@...nel.org>, Saravana Kannan <saravanak@...gle.com>,
	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>,
	Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	Dirk Behme <dirk.behme@...bosch.com>, linux-kernel@...r.kernel.org,
	devicetree@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v8 3/9] rust: device: Move property_present() to FwNode

(+Viresh, FYI)

On Wed, Jun 11, 2025 at 12:29:02PM +0200, Remo Senekowitsch wrote:
> The new FwNode abstraction will be used for accessing all device
> properties.
> 
> It would be possible to duplicate the methods on the device itself, but
> since some of the methods on Device would have different type sigatures
> as the ones on FwNode, this would only lead to inconsistency and
> confusion. For this reason, property_present is removed from Device and
> existing users are updated.
> 
> Signed-off-by: Remo Senekowitsch <remo@...nzli.dev>
> ---
>  drivers/cpufreq/rcpufreq_dt.rs | 3 ++-
>  rust/kernel/device.rs          | 7 -------
>  rust/kernel/device/property.rs | 7 +++++++
>  3 files changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/cpufreq/rcpufreq_dt.rs b/drivers/cpufreq/rcpufreq_dt.rs
> index 94ed81644fe1c..4eb240dc9fdc8 100644
> --- a/drivers/cpufreq/rcpufreq_dt.rs
> +++ b/drivers/cpufreq/rcpufreq_dt.rs
> @@ -20,7 +20,8 @@
>  /// Finds exact supply name from the OF node.
>  fn find_supply_name_exact(dev: &Device, name: &str) -> Option<CString> {
>      let prop_name = CString::try_from_fmt(fmt!("{}-supply", name)).ok()?;
> -    dev.property_present(&prop_name)
> +    dev.fwnode()?
> +        .property_present(&prop_name)
>          .then(|| CString::try_from_fmt(fmt!("{name}")).ok())
>          .flatten()
>  }
> diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
> index b69f03a7f8d30..241a395d529a1 100644
> --- a/rust/kernel/device.rs
> +++ b/rust/kernel/device.rs
> @@ -6,7 +6,6 @@
>  
>  use crate::{
>      bindings,
> -    str::CStr,
>      types::{ARef, Opaque},
>  };
>  use core::{fmt, marker::PhantomData, ptr};
> @@ -219,12 +218,6 @@ pub fn fwnode(&self) -> Option<&property::FwNode> {
>          // defined as a `#[repr(transparent)]` wrapper around `fwnode_handle`.
>          Some(unsafe { &*fwnode_handle.cast() })
>      }
> -
> -    /// Checks if property is present or not.
> -    pub fn property_present(&self, name: &CStr) -> bool {
> -        // SAFETY: By the invariant of `CStr`, `name` is null-terminated.
> -        unsafe { bindings::device_property_present(self.as_raw().cast_const(), name.as_char_ptr()) }
> -    }
>  }
>  
>  // SAFETY: `Device` is a transparent wrapper of a type that doesn't depend on `Device`'s generic
> diff --git a/rust/kernel/device/property.rs b/rust/kernel/device/property.rs
> index 03850b7bb8087..50c61aa056e6b 100644
> --- a/rust/kernel/device/property.rs
> +++ b/rust/kernel/device/property.rs
> @@ -8,6 +8,7 @@
>  
>  use crate::{
>      bindings,
> +    str::CStr,
>      types::{ARef, Opaque},
>  };
>  
> @@ -55,6 +56,12 @@ unsafe fn from_raw(raw: *mut bindings::fwnode_handle) -> ARef<Self> {
>      pub(crate) fn as_raw(&self) -> *mut bindings::fwnode_handle {
>          self.0.get()
>      }
> +
> +    /// Checks if property is present or not.
> +    pub fn property_present(&self, name: &CStr) -> bool {
> +        // SAFETY: By the invariant of `CStr`, `name` is null-terminated.
> +        unsafe { bindings::fwnode_property_present(self.as_raw().cast_const(), name.as_char_ptr()) }
> +    }
>  }
>  
>  // SAFETY: Instances of `FwNode` are always reference-counted.
> -- 
> 2.49.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ