aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
Diffstat (limited to 'rust')
-rw-r--r--rust/helpers/helpers.c1
-rw-r--r--rust/helpers/of.c8
-rw-r--r--rust/kernel/device/property.rs7
3 files changed, 16 insertions, 0 deletions
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index 393ad201befb..0b09bd0e3561 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -28,6 +28,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 2f6f3ef17db7..49ee12a906db 100644
--- a/rust/kernel/device/property.rs
+++ b/rust/kernel/device/property.rs
@@ -61,6 +61,13 @@ impl FwNode {
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.
///