[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <42a5af26-8b86-45ce-8432-d7980a185bde@de.bosch.com>
Date: Thu, 24 Oct 2024 11:11:50 +0200
From: Dirk Behme <dirk.behme@...bosch.com>
To: Danilo Krummrich <dakr@...nel.org>, <gregkh@...uxfoundation.org>,
<rafael@...nel.org>, <bhelgaas@...gle.com>, <ojeda@...nel.org>,
<alex.gaynor@...il.com>, <boqun.feng@...il.com>, <gary@...yguo.net>,
<bjorn3_gh@...tonmail.com>, <benno.lossin@...ton.me>, <tmgross@...ch.edu>,
<a.hindborg@...sung.com>, <aliceryhl@...gle.com>, <airlied@...il.com>,
<fujita.tomonori@...il.com>, <lina@...hilina.net>, <pstanner@...hat.com>,
<ajanulgu@...hat.com>, <lyude@...hat.com>, <robh@...nel.org>,
<daniel.almeida@...labora.com>, <saravanak@...gle.com>
CC: <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-pci@...r.kernel.org>, <devicetree@...r.kernel.org>
Subject: Re: [PATCH v3 15/16] rust: platform: add basic platform device /
driver abstractions
Hi Danilo,
On 22.10.2024 23:31, Danilo Krummrich wrote:
> Implement the basic platform bus abstractions required to write a basic
> platform driver. This includes the following data structures:
>
> The `platform::Driver` trait represents the interface to the driver and
> provides `pci::Driver::probe` for the driver to implement.
>
> The `platform::Device` abstraction represents a `struct platform_device`.
>
> In order to provide the platform bus specific parts to a generic
> `driver::Registration` the `driver::RegistrationOps` trait is implemented
> by `platform::Adapter`.
>
> Signed-off-by: Danilo Krummrich <dakr@...nel.org>
> ---
> MAINTAINERS | 1 +
> rust/bindings/bindings_helper.h | 1 +
> rust/helpers/helpers.c | 1 +
> rust/helpers/platform.c | 13 ++
> rust/kernel/lib.rs | 1 +
> rust/kernel/platform.rs | 217 ++++++++++++++++++++++++++++++++
> 6 files changed, 234 insertions(+)
> create mode 100644 rust/helpers/platform.c
> create mode 100644 rust/kernel/platform.rs
...
> diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
> new file mode 100644
> index 000000000000..addf5356f44f
> --- /dev/null
> +++ b/rust/kernel/platform.rs
....
> +/// Declares a kernel module that exposes a single platform driver.
> +///
> +/// # Examples
> +///
> +/// ```ignore
> +/// kernel::module_platform_driver! {
> +/// type: MyDriver,
> +/// name: "Module name",
> +/// author: "Author name",
> +/// description: "Description",
> +/// license: "GPL v2",
> +/// }
> +/// ```
> +#[macro_export]
> +macro_rules! module_platform_driver {
> + ($($f:tt)*) => {
> + $crate::module_driver!(<T>, $crate::platform::Adapter<T>, { $($f)* });
> + };
> +}
> +
> +/// IdTable type for platform drivers.
> +pub type IdTable<T> = &'static dyn kernel::device_id::IdTable<of::DeviceId, T>;
> +
> +/// The platform driver trait.
> +///
> +/// # Example
> +///
> +///```
> +/// # use kernel::{bindings, c_str, of, platform};
> +///
> +/// struct MyDriver;
> +///
> +/// kernel::of_device_table!(
> +/// OF_TABLE,
> +/// MODULE_OF_TABLE,
It looks to me that OF_TABLE and MODULE_OF_TABLE are quite generic names
used here. Shouldn't they be somehow driver specific, e.g.
OF_TABLE_MYDRIVER and MODULE_OF_TABLE_MYDRIVER or whatever? Same for the
other examples/samples in this patch series. Found that while using the
*same* somewhere else ;)
Best regards
Dirk
Powered by blists - more mailing lists