[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250618131958.GA1550757-robh@kernel.org>
Date: Wed, 18 Jun 2025 08:19:58 -0500
From: Rob Herring <robh@...nel.org>
To: Igor Korotin <igor.korotin.linux@...il.com>
Cc: ojeda@...nel.org, alex.gaynor@...il.com, rafael@...nel.org,
gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-acpi@...r.kernel.org,
boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
benno.lossin@...ton.me, a.hindborg@...nel.org, aliceryhl@...gle.com,
tmgross@...ch.edu, dakr@...nel.org, lenb@...nel.org,
wedsonaf@...il.com, viresh.kumar@...aro.org, alex.hung@....com,
dingxiangfei2009@...il.com
Subject: Re: [PATCH v7 3/9] samples: rust: platform: conditionally call
Self::properties_parse()
On Wed, Jun 18, 2025 at 11:13:25AM +0100, Igor Korotin wrote:
> From: Danilo Krummrich <dakr@...nel.org>
>
> Only call Self::properties_parse() when the device is compatible with
> "test,rust-device".
>
> Once we add ACPI support, we don't want the ACPI device to fail probing
> in Self::properties_parse().
>
> Signed-off-by: Danilo Krummrich <dakr@...nel.org>
This needs your S-o-b as well since you sent the patch.
> ---
> samples/rust/rust_driver_platform.rs | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/samples/rust/rust_driver_platform.rs b/samples/rust/rust_driver_platform.rs
> index 000bb915af60..036dd0b899b0 100644
> --- a/samples/rust/rust_driver_platform.rs
> +++ b/samples/rust/rust_driver_platform.rs
> @@ -40,7 +40,12 @@ fn probe(
> dev_info!(dev, "Probed with info: '{}'.\n", info.0);
> }
>
> - Self::properties_parse(dev)?;
> + if dev
> + .fwnode()
> + .is_some_and(|node| node.is_compatible(c_str!("test,rust-device")))
I think you should be checking just is this ACPI or DT rather than
compatible. It's kind of an anti-pattern to test compatible in probe.
The reason is we've already matched to a compatible and have match data
to use, so we don't need to do it again. It becomes quite messy when
there are numerous possible compatibles.
In C, we just do 'if (dev->of_node)' to check for DT or not.
It is just a sample, but I'm sure folks will copy it.
Rob
Powered by blists - more mailing lists