Skip to content

Commit 8acbde0

Browse files
senekorjannau
authored andcommitted
rust: device: Move property_present() to FwNode
The new FwNode abstraction will be used for accessing all device properties. It would be possible to duplicate the methods on the device itself, but since some of the methods on Device would have different type sigatures as the ones on FwNode, this would only lead to inconsistency and confusion. For this reason, property_present is removed from Device and existing users are updated. Signed-off-by: Remo Senekowitsch <remo@buenzli.dev> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 49d8217 commit 8acbde0

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

rust/kernel/device/property.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use core::ptr;
88

99
use crate::{
1010
bindings,
11+
str::CStr,
1112
types::{ARef, Opaque},
1213
};
1314

@@ -55,6 +56,12 @@ impl FwNode {
5556
pub(crate) fn as_raw(&self) -> *mut bindings::fwnode_handle {
5657
self.0.get()
5758
}
59+
60+
/// Checks if property is present or not.
61+
pub fn property_present(&self, name: &CStr) -> bool {
62+
// SAFETY: By the invariant of `CStr`, `name` is null-terminated.
63+
unsafe { bindings::fwnode_property_present(self.as_raw().cast_const(), name.as_char_ptr()) }
64+
}
5865
}
5966

6067
// SAFETY: Instances of `FwNode` are always reference-counted.

0 commit comments

Comments
 (0)