mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
synced 2025-04-19 20:58:31 +09:00
rust: module: introduce authors
key
In the `module!` macro, the `author` field is currently of type `String`. Since modules can have multiple authors, this limitation prevents specifying more than one. Add an `authors` field as `Option<Vec<String>>` to allow creating modules with multiple authors, and change the documentation and all current users to use it. Eventually, the single `author` field may be removed. [ The `modinfo` key needs to still be `author`; otherwise, tooling may not work properly, e.g.: $ modinfo --author samples/rust/rust_print.ko Rust for Linux Contributors I have also kept the original `author` field (undocumented), so that we can drop it more easily in a kernel cycle or two. - Miguel ] Suggested-by: Miguel Ojeda <ojeda@kernel.org> Link: https://github.com/Rust-for-Linux/linux/issues/244 Reviewed-by: Charalampos Mitrodimas <charmitro@posteo.net> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Signed-off-by: Guilherme Giacomo Simoes <trintaeoitogc@gmail.com> Link: https://lore.kernel.org/r/20250309175712.845622-2-trintaeoitogc@gmail.com [ Fixed `modinfo` key. Kept `author` field. Reworded message accordingly. Updated my email. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
fc2f191f85
commit
38559da6af
@ -27,7 +27,7 @@ use kernel::{
|
||||
module! {
|
||||
type: NullBlkModule,
|
||||
name: "rnull_mod",
|
||||
author: "Andreas Hindborg",
|
||||
authors: ["Andreas Hindborg"],
|
||||
description: "Rust implementation of the C null block driver",
|
||||
license: "GPL v2",
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ kernel::module_phy_driver! {
|
||||
DeviceId::new_with_driver::<PhyAX88796B>()
|
||||
],
|
||||
name: "rust_asix_phy",
|
||||
author: "FUJITA Tomonori <fujita.tomonori@gmail.com>",
|
||||
authors: ["FUJITA Tomonori <fujita.tomonori@gmail.com>"],
|
||||
description: "Rust Asix PHYs driver",
|
||||
license: "GPL",
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ kernel::module_phy_driver! {
|
||||
phy::DeviceId::new_with_driver::<PhyQT2025>(),
|
||||
],
|
||||
name: "qt2025_phy",
|
||||
author: "FUJITA Tomonori <fujita.tomonori@gmail.com>",
|
||||
authors: ["FUJITA Tomonori <fujita.tomonori@gmail.com>"],
|
||||
description: "AMCC QT2025 PHY driver",
|
||||
license: "GPL",
|
||||
firmware: ["qt2025-2.0.3.3.fw"],
|
||||
|
@ -790,7 +790,7 @@ impl DeviceMask {
|
||||
/// DeviceId::new_with_driver::<PhySample>()
|
||||
/// ],
|
||||
/// name: "rust_sample_phy",
|
||||
/// author: "Rust for Linux Contributors",
|
||||
/// authors: ["Rust for Linux Contributors"],
|
||||
/// description: "Rust sample PHYs driver",
|
||||
/// license: "GPL",
|
||||
/// }
|
||||
@ -819,7 +819,7 @@ impl DeviceMask {
|
||||
/// module! {
|
||||
/// type: Module,
|
||||
/// name: "rust_sample_phy",
|
||||
/// author: "Rust for Linux Contributors",
|
||||
/// authors: ["Rust for Linux Contributors"],
|
||||
/// description: "Rust sample PHYs driver",
|
||||
/// license: "GPL",
|
||||
/// }
|
||||
|
@ -103,7 +103,7 @@ impl<T: Driver + 'static> Adapter<T> {
|
||||
/// kernel::module_pci_driver! {
|
||||
/// type: MyDriver,
|
||||
/// name: "Module name",
|
||||
/// author: "Author name",
|
||||
/// authors: ["Author name"],
|
||||
/// description: "Description",
|
||||
/// license: "GPL v2",
|
||||
/// }
|
||||
|
@ -101,7 +101,7 @@ impl<T: Driver + 'static> driver::Adapter for Adapter<T> {
|
||||
/// kernel::module_platform_driver! {
|
||||
/// type: MyDriver,
|
||||
/// name: "Module name",
|
||||
/// author: "Author name",
|
||||
/// authors: ["Author name"],
|
||||
/// description: "Description",
|
||||
/// license: "GPL v2",
|
||||
/// }
|
||||
|
@ -37,7 +37,7 @@ use proc_macro::TokenStream;
|
||||
/// module!{
|
||||
/// type: MyModule,
|
||||
/// name: "my_kernel_module",
|
||||
/// author: "Rust for Linux Contributors",
|
||||
/// authors: ["Rust for Linux Contributors"],
|
||||
/// description: "My very own kernel module!",
|
||||
/// license: "GPL",
|
||||
/// alias: ["alternate_module_name"],
|
||||
@ -70,7 +70,7 @@ use proc_macro::TokenStream;
|
||||
/// module!{
|
||||
/// type: MyDeviceDriverModule,
|
||||
/// name: "my_device_driver_module",
|
||||
/// author: "Rust for Linux Contributors",
|
||||
/// authors: ["Rust for Linux Contributors"],
|
||||
/// description: "My device driver requires firmware",
|
||||
/// license: "GPL",
|
||||
/// firmware: ["my_device_firmware1.bin", "my_device_firmware2.bin"],
|
||||
@ -89,7 +89,7 @@ use proc_macro::TokenStream;
|
||||
/// # Supported argument types
|
||||
/// - `type`: type which implements the [`Module`] trait (required).
|
||||
/// - `name`: ASCII string literal of the name of the kernel module (required).
|
||||
/// - `author`: string literal of the author of the kernel module.
|
||||
/// - `authors`: array of ASCII string literals of the authors of the kernel module.
|
||||
/// - `description`: string literal of the description of the kernel module.
|
||||
/// - `license`: ASCII string literal of the license of the kernel module (required).
|
||||
/// - `alias`: array of ASCII string literals of the alias names of the kernel module.
|
||||
|
@ -95,6 +95,7 @@ struct ModuleInfo {
|
||||
license: String,
|
||||
name: String,
|
||||
author: Option<String>,
|
||||
authors: Option<Vec<String>>,
|
||||
description: Option<String>,
|
||||
alias: Option<Vec<String>>,
|
||||
firmware: Option<Vec<String>>,
|
||||
@ -108,6 +109,7 @@ impl ModuleInfo {
|
||||
"type",
|
||||
"name",
|
||||
"author",
|
||||
"authors",
|
||||
"description",
|
||||
"license",
|
||||
"alias",
|
||||
@ -136,6 +138,7 @@ impl ModuleInfo {
|
||||
"type" => info.type_ = expect_ident(it),
|
||||
"name" => info.name = expect_string_ascii(it),
|
||||
"author" => info.author = Some(expect_string(it)),
|
||||
"authors" => info.authors = Some(expect_string_array(it)),
|
||||
"description" => info.description = Some(expect_string(it)),
|
||||
"license" => info.license = expect_string_ascii(it),
|
||||
"alias" => info.alias = Some(expect_string_array(it)),
|
||||
@ -186,6 +189,11 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
|
||||
if let Some(author) = info.author {
|
||||
modinfo.emit("author", &author);
|
||||
}
|
||||
if let Some(authors) = info.authors {
|
||||
for author in authors {
|
||||
modinfo.emit("author", &author);
|
||||
}
|
||||
}
|
||||
if let Some(description) = info.description {
|
||||
modinfo.emit("description", &description);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use kernel::{c_str, faux, prelude::*, Module};
|
||||
module! {
|
||||
type: SampleModule,
|
||||
name: "rust_faux_driver",
|
||||
author: "Lyude Paul",
|
||||
authors: ["Lyude Paul"],
|
||||
description: "Rust faux device sample",
|
||||
license: "GPL",
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ impl Drop for SampleDriver {
|
||||
kernel::module_pci_driver! {
|
||||
type: SampleDriver,
|
||||
name: "rust_driver_pci",
|
||||
author: "Danilo Krummrich",
|
||||
authors: ["Danilo Krummrich"],
|
||||
description: "Rust PCI driver",
|
||||
license: "GPL v2",
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ impl Drop for SampleDriver {
|
||||
kernel::module_platform_driver! {
|
||||
type: SampleDriver,
|
||||
name: "rust_driver_platform",
|
||||
author: "Danilo Krummrich",
|
||||
authors: ["Danilo Krummrich"],
|
||||
description: "Rust Platform driver",
|
||||
license: "GPL v2",
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use kernel::prelude::*;
|
||||
module! {
|
||||
type: RustMinimal,
|
||||
name: "rust_minimal",
|
||||
author: "Rust for Linux Contributors",
|
||||
authors: ["Rust for Linux Contributors"],
|
||||
description: "Rust minimal sample",
|
||||
license: "GPL",
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ const RUST_MISC_DEV_SET_VALUE: u32 = _IOW::<i32>('|' as u32, 0x82);
|
||||
module! {
|
||||
type: RustMiscDeviceModule,
|
||||
name: "rust_misc_device",
|
||||
author: "Lee Jones",
|
||||
authors: ["Lee Jones"],
|
||||
description: "Rust misc device sample",
|
||||
license: "GPL",
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use kernel::prelude::*;
|
||||
module! {
|
||||
type: RustPrint,
|
||||
name: "rust_print",
|
||||
author: "Rust for Linux Contributors",
|
||||
authors: ["Rust for Linux Contributors"],
|
||||
description: "Rust printing macros sample",
|
||||
license: "GPL",
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user