Skip to content

Commit c70386a

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 <j@jannau.net>
1 parent 84ba47b commit c70386a

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
@@ -274,6 +274,23 @@ impl Node {
274274
}
275275
}
276276

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

0 commit comments

Comments
 (0)