diff options
author | Danilo Krummrich <dakr@kernel.org> | 2024-12-19 18:04:03 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-12-20 17:19:25 +0100 |
commit | a790265c7f663c382ac25ecb841e241a023f0590 (patch) | |
tree | aacf999532ee25bc00a1f1bced7a9dd11277f13a /rust/kernel/lib.rs | |
parent | 5bcc8bfe841b29f7d62f4bb7738bb085ecc51aad (diff) |
rust: module: add trait `ModuleMetadata`
In order to access static metadata of a Rust kernel module, add the
`ModuleMetadata` trait.
In particular, this trait provides the name of a Rust kernel module as
specified by the `module!` macro.
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Tested-by: Dirk Behme <dirk.behme@de.bosch.com>
Tested-by: Fabien Parent <fabien.parent@linaro.org>
Link: https://lore.kernel.org/r/20241219170425.12036-2-dakr@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'rust/kernel/lib.rs')
-rw-r--r-- | rust/kernel/lib.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs index e1065a7551a3..61b82b78b915 100644 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@ -116,6 +116,12 @@ impl<T: Module> InPlaceModule for T { } } +/// Metadata attached to a [`Module`] or [`InPlaceModule`]. +pub trait ModuleMetadata { + /// The name of the module as specified in the `module!` macro. + const NAME: &'static crate::str::CStr; +} + /// Equivalent to `THIS_MODULE` in the C API. /// /// C header: [`include/linux/init.h`](srctree/include/linux/init.h) |