]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rust: module: add type `LocalModule`
authorDanilo Krummrich <dakr@kernel.org>
Thu, 6 Mar 2025 22:23:27 +0000 (23:23 +0100)
committerDanilo Krummrich <dakr@kernel.org>
Sun, 9 Mar 2025 18:21:08 +0000 (19:21 +0100)
The `LocalModule` type is the type of the module created by `module!`,
`module_pci_driver!`, `module_platform_driver!`, etc.

Since the exact type of the module is sometimes generated on the fly by
the listed macros, provide an alias.

This is first used by the `module_firmware!` macro.

Acked-by: Miguel Ojeda <ojeda@kernel.org>
Suggested-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20250306222336.23482-2-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/macros/module.rs

index cdf94f4982dfc109ac5c7e9001897555de19d67e..110e59c64197d6bd6fed36ec02f0a3ba38f5a9b0 100644 (file)
@@ -228,6 +228,10 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
                 kernel::ThisModule::from_ptr(core::ptr::null_mut())
             }};
 
+            /// The `LocalModule` type is the type of the module created by `module!`,
+            /// `module_pci_driver!`, `module_platform_driver!`, etc.
+            type LocalModule = {type_};
+
             impl kernel::ModuleMetadata for {type_} {{
                 const NAME: &'static kernel::str::CStr = kernel::c_str!(\"{name}\");
             }}