summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rust/bindings/bindings_helper.h1
-rw-r--r--rust/kernel/device.rs7
2 files changed, 8 insertions, 0 deletions
diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index e9fdceb568b8..55354e4dec14 100644
--- a/rust/bindings/bindings_helper.h
+++ b/rust/bindings/bindings_helper.h
@@ -26,6 +26,7 @@
#include <linux/pid_namespace.h>
#include <linux/platform_device.h>
#include <linux/poll.h>
+#include <linux/property.h>
#include <linux/refcount.h>
#include <linux/sched.h>
#include <linux/security.h>
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.