summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2025-06-20 16:15:04 +0100
committerDanilo Krummrich <dakr@kernel.org>2025-06-25 18:10:12 +0200
commit56a789f776f24e6b132ec00d4c27672ed4e2ec57 (patch)
tree4d8ffe9a30fa0a5eeda62ed67ec98ff9242281b5 /rust/kernel
parentc79cbde9b7bc7a650af96269588518950e3c2441 (diff)
rust: device: implement FwNode::is_of_node()
Implement FwNode::is_of_node() in order to check whether a FwNode instance is embedded in a struct device_node. Reviewed-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Igor Korotin <igor.korotin.linux@gmail.com> Link: https://lore.kernel.org/r/20250620151504.278766-1-igor.korotin.linux@gmail.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/device/property.rs7
1 files changed, 7 insertions, 0 deletions
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.
///