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@xxxxxxxxxx> --- 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