[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250530192856.1177011-4-remo@buenzli.dev>
Date: Fri, 30 May 2025 21:28:50 +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 <lossin@...nel.org>,
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 v7 3/9] rust: device: Add 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.
So, in the future, property_present will be removed from Device. However,
there's a user about to be merged, so the method is left to make merging
easier.
Signed-off-by: Remo Senekowitsch <remo@...nzli.dev>
---
rust/kernel/device/property.rs | 7 +++++++
1 file changed, 7 insertions(+)
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