[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aEVvGeG5mnIj2gw5@pollux>
Date: Sun, 8 Jun 2025 13:08:09 +0200
From: Danilo Krummrich <dakr@...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, lenb@...nel.org, wedsonaf@...il.com,
viresh.kumar@...aro.org, alex.hung@....com,
dingxiangfei2009@...il.com
Subject: Re: [PATCH v3 4/4] samples: rust: add ACPI match table example to
platform driver
On Fri, Jun 06, 2025 at 06:10:33PM +0100, Igor Korotin wrote:
> Extend the Rust sample platform driver to probe using device/driver name
> +/// OF/ACPI match tables for Platform Driver implementation
> +///
> +/// The platform::Driver requires declaration of both OF_ID_TABLE and
> +/// ACPI_ID_TABLE, but if driver is not going to use either of them
> +/// it can implement one of them or both as None.
> +///
> +/// # Example:
> +///
> +/// ```ignore
> +/// impl platform::Driver for SampleDriver {
> +/// type IdInfo = ();
> +/// const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = None;
> +/// const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = None;
> +///
> +/// fn probe(
> +/// pdev: &platform::Device<Core>,
> +/// _info: Option<&Self::IdInfo>,
> +/// ) -> Result<Pin<KBox<Self>>> {
> +/// dev_dbg!(pdev.as_ref(), "Probe Rust Platform driver sample.\n");
> +///
> +/// let drvdata = KBox::new(Self { pdev: pdev.into() }, GFP_KERNEL)?;
> +///
> +/// Ok(drvdata.into())
> +/// }
> +/// }
> +/// ```
What I meant with [1] was that I think we should make this code compile and
remove everything that's not needed, i.e.:
///```
/// # use kernel::{acpi, device::Core, of, platform};
///
/// struct MyDriver;
///
/// impl platform::Driver for MyDriver {
/// type IdInfo = ();
/// const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = None;
/// const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = None;
///
/// fn probe(
/// _pdev: &platform::Device<Core>,
/// _id_info: Option<&Self::IdInfo>,
/// ) -> Result<Pin<KBox<Self>>> {
/// Err(ENODEV)
/// }
/// }
///```
However, given that we can't run doctests from drivers yet, we should just
remove this doctest I think. It much more belongs into rust/kernel/platform.rs
anyways (where we already have a similar one).
[1] https://lore.kernel.org/lkml/aEL0AGBZqDp1lMFe@pollux/
Powered by blists - more mailing lists