[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250504173154.488519-4-remo@buenzli.dev>
Date: Sun, 4 May 2025 19:31:48 +0200
From: Remo Senekowitsch <remo@...nzli.dev>
To: 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 <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Dirk Behme <dirk.behme@...bosch.com>,
Remo Senekowitsch <remo@...nzli.dev>
Cc: linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org,
rust-for-linux@...r.kernel.org
Subject: [PATCH v4 3/9] rust: device: Move property_present() to FwNode
The new FwNode abstraction will be used for accessing all device
properties, so it must have the property_present method.
It's 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.
Hence, remove the method from Device.
There aren't any users to update yet.
Signed-off-by: Remo Senekowitsch <remo@...nzli.dev>
---
rust/kernel/device/mod.rs | 7 -------
rust/kernel/device/property.rs | 8 +++++++-
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/rust/kernel/device/mod.rs b/rust/kernel/device/mod.rs
index b4b7056eb80f8..15d89cd45e871 100644
--- a/rust/kernel/device/mod.rs
+++ b/rust/kernel/device/mod.rs
@@ -6,7 +6,6 @@
use crate::{
bindings,
- str::CStr,
types::{ARef, Opaque},
};
use core::{fmt, marker::PhantomData, ptr};
@@ -200,12 +199,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 e75d55f5856cf..70593343bd811 100644
--- a/rust/kernel/device/property.rs
+++ b/rust/kernel/device/property.rs
@@ -6,7 +6,7 @@
use core::ptr;
-use crate::{bindings, types::Opaque};
+use crate::{bindings, str::CStr, types::Opaque};
/// A reference-counted fwnode_handle.
///
@@ -31,6 +31,12 @@ impl FwNode {
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