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>
This commit is contained in:
Danilo Krummrich
2025-06-20 16:15:04 +01:00
parent c79cbde9b7
commit 56a789f776
4 changed files with 17 additions and 0 deletions
+7
View File
@@ -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.
///