diff options
Diffstat (limited to 'rust/kernel/device/property.rs')
-rw-r--r-- | rust/kernel/device/property.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/rust/kernel/device/property.rs b/rust/kernel/device/property.rs index 82ef54b54f18..ed17b20f7ae1 100644 --- a/rust/kernel/device/property.rs +++ b/rust/kernel/device/property.rs @@ -8,6 +8,7 @@ use core::ptr; use crate::{ bindings, + str::CStr, types::{ARef, Opaque}, }; @@ -56,6 +57,12 @@ impl FwNode { pub(crate) fn as_raw(&self) -> *mut bindings::fwnode_handle { self.0.get() } + + /// Checks if property is present or not. + pub fn property_present(&self, name: &CStr) -> bool { + // SAFETY: By the invariant of `CStr`, `name` is null-terminated. + unsafe { bindings::fwnode_property_present(self.as_raw().cast_const(), name.as_char_ptr()) } + } } // SAFETY: Instances of `FwNode` are always reference-counted. |