diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2025-01-13 14:22:59 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-01-15 20:22:34 +0300 |
commit | e3a89cc281b60fbd39fa6c1509e80001b77fd8c1 (patch) | |
tree | 5082be36c93a240d8be7c0a849119b0c98a04466 /rust/kernel | |
parent | f7862dfef6612b87b2ad8352c4d73886f09456d6 (diff) | |
download | linux-e3a89cc281b60fbd39fa6c1509e80001b77fd8c1.tar.xz |
rust: device: Add property_present()
This implements Device::property_present(), which calls C APIs
device_property_present() helper.
The new helper will be used by Rust based cpufreq drivers.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/f43fe3f7b3151a89c261ad728b0f3bb2fc24caef.1736766672.git.viresh.kumar@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'rust/kernel')
-rw-r--r-- | rust/kernel/device.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs index c926e0c2b852..eadc6160a4be 100644 --- a/rust/kernel/device.rs +++ b/rust/kernel/device.rs @@ -6,6 +6,7 @@ use crate::{ bindings, + str::CString, types::{ARef, Opaque}, }; use core::{fmt, ptr}; @@ -180,6 +181,12 @@ impl Device { ) }; } + + /// Checks if property is present or not. + pub fn property_present(&self, name: &CString) -> bool { + // SAFETY: By the invariant of `CString`, `name` is null-terminated. + unsafe { bindings::device_property_present(self.as_raw().cast_const(), name.as_ptr() as *const _) } + } } // SAFETY: Instances of `Device` are always reference-counted. |