Skip to content

Commit e3a89cc

Browse files
vireshkgregkh
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/f43fe3f7b3151a89c261ad728b0f3bb2fc24caef.1736766672.git.viresh.kumar@linaro.org Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f7862df commit e3a89cc

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

rust/bindings/bindings_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/pid_namespace.h>
2727
#include <linux/platform_device.h>
2828
#include <linux/poll.h>
29+
#include <linux/property.h>
2930
#include <linux/refcount.h>
3031
#include <linux/sched.h>
3132
#include <linux/security.h>

rust/kernel/device.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
use crate::{
88
bindings,
9+
str::CString,
910
types::{ARef, Opaque},
1011
};
1112
use core::{fmt, ptr};
@@ -180,6 +181,12 @@ impl Device {
180181
)
181182
};
182183
}
184+
185+
/// Checks if property is present or not.
186+
pub fn property_present(&self, name: &CString) -> bool {
187+
// SAFETY: By the invariant of `CString`, `name` is null-terminated.
188+
unsafe { bindings::device_property_present(self.as_raw().cast_const(), name.as_ptr() as *const _) }
189+
}
183190
}
184191

185192
// SAFETY: Instances of `Device` are always reference-counted.

0 commit comments

Comments
 (0)