[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250620151504.278766-1-igor.korotin.linux@gmail.com>
Date: Fri, 20 Jun 2025 16:15:04 +0100
From: Igor Korotin <igor.korotin.linux@...il.com>
To: "Rafael J . Wysocki" <rafael@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Miguel Ojeda <ojeda@...nel.org>,
Rob Herring <robh@...nel.org>,
Saravana Kannan <saravanak@...gle.com>
Cc: Alex Hung <alex.hung@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Igor Korotin <igor.korotin.linux@...il.com>,
Jakub Kicinski <kuba@...nel.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
Remo Senekowitsch <remo@...nzli.dev>,
Tamir Duberstein <tamird@...il.com>,
Viresh Kumar <viresh.kumar@...aro.org>,
Wedson Almeida Filho <wedsonaf@...il.com>,
Xiangfei Ding <dingxiangfei2009@...il.com>,
devicetree@...r.kernel.org,
linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Alice Ryhl <aliceryhl@...gle.com>,
Andreas Hindborg <a.hindborg@...nel.org>,
Benno Lossin <lossin@...nel.org>,
Boqun Feng <boqun.feng@...il.com>,
Danilo Krummrich <dakr@...nel.org>,
Gary Guo <gary@...yguo.net>,
Len Brown <lenb@...nel.org>,
Trevor Gross <tmgross@...ch.edu>
Subject: [PATCH v8 1/9] rust: device: implement FwNode::is_of_node()
From: Danilo Krummrich <dakr@...nel.org>
Implement FwNode::is_of_node() in order to check whether a FwNode
instance is embedded in a struct device_node.
Signed-off-by: Danilo Krummrich <dakr@...nel.org>
Signed-off-by: Igor Korotin <igor.korotin.linux@...il.com>
---
MAINTAINERS | 1 +
rust/helpers/helpers.c | 1 +
rust/helpers/of.c | 8 ++++++++
rust/kernel/device/property.rs | 7 +++++++
4 files changed, 17 insertions(+)
create mode 100644 rust/helpers/of.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 9f724cd556f4..1e918319cff4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18579,6 +18579,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
F: Documentation/ABI/testing/sysfs-firmware-ofw
F: drivers/of/
F: include/linux/of*.h
+F: rust/helpers/of.c
F: rust/kernel/of.rs
F: scripts/dtc/
F: tools/testing/selftests/dt/
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index ed00695af971..041a8112eb9e 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -26,6 +26,7 @@
#include "kunit.c"
#include "mm.c"
#include "mutex.c"
+#include "of.c"
#include "page.c"
#include "platform.c"
#include "pci.c"
diff --git a/rust/helpers/of.c b/rust/helpers/of.c
new file mode 100644
index 000000000000..86b51167c913
--- /dev/null
+++ b/rust/helpers/of.c
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/of.h>
+
+bool rust_helper_is_of_node(const struct fwnode_handle *fwnode)
+{
+ return is_of_node(fwnode);
+}
diff --git a/rust/kernel/device/property.rs b/rust/kernel/device/property.rs
index 838509111e57..63fe4b6ee6bc 100644
--- a/rust/kernel/device/property.rs
+++ b/rust/kernel/device/property.rs
@@ -61,6 +61,13 @@ pub(crate) fn as_raw(&self) -> *mut bindings::fwnode_handle {
self.0.get()
}
+ /// Returns `true` if `&self` is an OF node, `false` otherwise.
+ pub fn is_of_node(&self) -> bool {
+ // SAFETY: The type invariant of `Self` guarantees that `self.as_raw() is a pointer to a
+ // valid `struct fwnode_handle`.
+ unsafe { bindings::is_of_node(self.as_raw()) }
+ }
+
/// Returns an object that implements [`Display`](core::fmt::Display) for
/// printing the name of a node.
///
--
2.43.0
Powered by blists - more mailing lists