Commit 56a789f7 authored by Danilo Krummrich's avatar Danilo Krummrich
Browse files

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: default avatarRob Herring (Arm) <robh@kernel.org>
Signed-off-by: default avatarIgor Korotin <igor.korotin.linux@gmail.com>
Link: https://lore.kernel.org/r/20250620151504.278766-1-igor.korotin.linux@gmail.com


Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent c79cbde9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -18580,6 +18580,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/
+1 −0
Original line number Diff line number Diff line
@@ -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"

rust/helpers/of.c

0 → 100644
+8 −0
Original line number Diff line number Diff line
// 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);
}
+7 −0
Original line number Diff line number Diff line
@@ -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.
    ///