From: "Remo Senekowitsch" <remo@buenzli.dev>
To: "Danilo Krummrich" <dakr@kernel.org>, "Rob Herring" <robh@kernel.org>
Cc: "Saravana Kannan" <saravanak@google.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Mark Brown" <broonie@kernel.org>,
"Dirk Behme" <dirk.behme@de.bosch.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v1 3/3] samples: rust: platform: Add property child and reference args examples
Date: Wed, 18 Jun 2025 13:37:08 +0200 [thread overview]
Message-ID: <DAPMND2X0QHE.1N0NF7R1F8J1G@buenzli.dev> (raw)
In-Reply-To: <aFFpmKLKR2hGs1I1@pollux>
On Tue Jun 17, 2025 at 3:11 PM CEST, Danilo Krummrich wrote:
> On Tue, Jun 17, 2025 at 08:01:08AM -0500, Rob Herring wrote:
>> On Mon, Jun 16, 2025 at 10:45 AM Remo Senekowitsch <remo@buenzli.dev> wrote:
>> > @@ -91,6 +95,13 @@ fn properties_parse(dev: &device::Device) -> Result {
>> > 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)?;
>>
>> Is there some reason we can just pass 2 in rather than nargs? Seems
>> overly verbose for my tastes.
>
> It's because you could also pass NArgs::Prop("foo-bar") to indicate the the
> name of the property telling the number of arguments.
>
> NArgs is defined as
>
> pub enum NArgs<'a> {
> /// The name of the property of the reference indicating the number of
> /// arguments.
> Prop(&'a CStr),
> /// The known number of arguments.
> N(u32),
> }
>
> and FwNode::property_get_reference_args() can match against the corresponding
> enum variant to cover both cases.
I guess we could make the function generic if that's deemed worth it?
A trait and an implementation for `u32` and `&CStr` each. Similar to how
we made `property_read` generic.
>> > + dev_info!(dev, "'{name}'='{prop:?}'\n");
>> > + }
>> > +
>> > Ok(())
>> > }
>> > }
>> > --
>> > 2.49.0
>> >
next prev parent reply other threads:[~2025-06-18 11:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 15:45 [PATCH v1 0/3] Add Rust bindings for device property child nodes and reference args Remo Senekowitsch
2025-06-16 15:45 ` [PATCH v1 1/3] rust: device: Add child accessor and iterator Remo Senekowitsch
2025-06-16 15:45 ` [PATCH v1 2/3] rust: device: Add property_get_reference_args Remo Senekowitsch
2025-06-16 15:45 ` [PATCH v1 3/3] samples: rust: platform: Add property child and reference args examples Remo Senekowitsch
2025-06-17 13:01 ` Rob Herring
2025-06-17 13:11 ` Danilo Krummrich
2025-06-18 11:37 ` Remo Senekowitsch [this message]
2025-06-18 13:31 ` Rob Herring
2025-06-18 14:16 ` Danilo Krummrich
2025-06-20 22:37 ` Danilo Krummrich
2025-06-25 14:39 ` Rob Herring
2025-06-25 15:09 ` Danilo Krummrich
2025-06-25 15:12 ` Rob Herring
2025-06-25 16:08 ` [PATCH v1 0/3] Add Rust bindings for device property child nodes and reference args Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DAPMND2X0QHE.1N0NF7R1F8J1G@buenzli.dev \
--to=remo@buenzli.dev \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=broonie@kernel.org \
--cc=dakr@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dirk.behme@de.bosch.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=saravanak@google.com \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®