From: Danilo Krummrich <dakr@kernel.org>
To: Rob Herring <robh@kernel.org>
Cc: "Remo Senekowitsch" <remo@buenzli.dev>,
"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 16:16:10 +0200 [thread overview]
Message-ID: <aFLKKr1bQue9iuTk@pollux> (raw)
In-Reply-To: <20250618133155.GB1550757-robh@kernel.org>
On Wed, Jun 18, 2025 at 08:31:55AM -0500, Rob Herring wrote:
> On Wed, Jun 18, 2025 at 01:37:08PM +0200, Remo Senekowitsch wrote:
> > 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.
I don't think that's worth it; I think the current version is fine as it is.
> There is a case where the cells property is optional and we fallback to
> 0 cells if not found. #msi-cells is an example. I imagine NArgs could
> express that while a generic could not? In any case, I don't expect
> drivers to have to deal with that as it would be subsystem code handling
> it.
>
> As-is is fine I think. This function isn't too widely used that it could
> be changed later if we change our minds.
Agreed.
next prev parent reply other threads:[~2025-06-18 14:16 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
2025-06-18 13:31 ` Rob Herring
2025-06-18 14:16 ` Danilo Krummrich [this message]
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=aFLKKr1bQue9iuTk@pollux \
--to=dakr@kernel.org \
--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=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=remo@buenzli.dev \
--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;
as well as URLs for NNTP newsgroup(s).