Skip to content

Commit 371f5ed

Browse files
committed
rust: of: Add wrapper for of_property_present()
Used by aop_audio which can't use device::Device::property_present() since it is not a fully populated device. Signed-off-by: Janne Grunau <[email protected]>
1 parent 7cf4b06 commit 371f5ed

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

rust/helpers/of.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ bool rust_helper_of_node_is_root(const struct device_node *np)
1414
{
1515
return of_node_is_root(np);
1616
}
17+
18+
bool rust_helper_of_property_present(const struct device_node *np, const char *propname)
19+
{
20+
return of_property_present(np, propname);
21+
}
1722
#endif
1823

1924
struct device_node *rust_helper_of_parse_phandle(const struct device_node *np,

rust/kernel/of.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,23 @@ impl Node {
273273
}
274274
}
275275

276+
#[allow(unused_variables)]
277+
/// Check whether node property exists.
278+
pub fn property_present(&self, propname: &CStr) -> bool {
279+
#[cfg(not(CONFIG_OF))]
280+
{
281+
false
282+
}
283+
#[cfg(CONFIG_OF)]
284+
// SAFETY: `raw_node` is valid per the type invariant.
285+
unsafe {
286+
bool::from(bindings::of_property_present(
287+
self.raw_node,
288+
propname.as_char_ptr(),
289+
))
290+
}
291+
}
292+
276293
#[allow(unused_variables)]
277294
/// Look up a node property by name, returning a `Property` object if found.
278295
pub fn find_property(&self, propname: &CStr) -> Option<Property<'_>> {

0 commit comments

Comments
 (0)