diff options
| author | Remo Senekowitsch <[email protected]> | 2025-06-16 15:45:11 +0000 |
|---|---|---|
| committer | Danilo Krummrich <[email protected]> | 2025-06-25 15:48:41 +0000 |
| commit | c79cbde9b7bc7a650af96269588518950e3c2441 (patch) | |
| tree | 92da49bc9289a3a8dc64f7687ef2de9af4d6910f /samples/rust/rust_driver_platform.rs | |
| parent | rust: device: Add property_get_reference_args (diff) | |
| download | kernel-c79cbde9b7bc7a650af96269588518950e3c2441.tar.gz kernel-c79cbde9b7bc7a650af96269588518950e3c2441.zip | |
samples: rust: platform: Add property child and reference args examples
Add some example usage of the device property methods for reading
DT/ACPI/swnode child nodes and reference args.
Signed-off-by: Remo Senekowitsch <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[ Convert 'child@{0,1}' to 'child-{0,1}'; skip child nodes without
'compatible' property in of_unittest_platform_populate() as proposed
by Rob Herring. - Danilo]
Signed-off-by: Danilo Krummrich <[email protected]>
Diffstat (limited to 'samples/rust/rust_driver_platform.rs')
| -rw-r--r-- | samples/rust/rust_driver_platform.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/samples/rust/rust_driver_platform.rs b/samples/rust/rust_driver_platform.rs index c0abf78d0683..4dcedb22a4bb 100644 --- a/samples/rust/rust_driver_platform.rs +++ b/samples/rust/rust_driver_platform.rs @@ -4,7 +4,11 @@ use kernel::{ c_str, - device::{self, Core}, + device::{ + self, + property::{FwNodeReferenceArgs, NArgs}, + Core, + }, of, platform, prelude::*, str::CString, @@ -91,6 +95,13 @@ impl SampleDriver { let prop: KVec<i16> = fwnode.property_read_array_vec(name, 4)?.required_by(dev)?; dev_info!(dev, "'{name}'='{prop:?}' (KVec)\n"); + for child in fwnode.children() { + let name = c_str!("test,ref-arg"); + let nargs = NArgs::N(2); + let prop: FwNodeReferenceArgs = child.property_get_reference_args(name, nargs, 0)?; + dev_info!(dev, "'{name}'='{prop:?}'\n"); + } + Ok(()) } } |
