mirror of
https://github.com/torvalds/linux.git
synced 2025-11-03 18:20:25 +02: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
14 changed files with 24 additions and 16 deletions
|
|
@ -27,7 +27,7 @@
|
||||||
module! {
|
module! {
|
||||||
type: NullBlkModule,
|
type: NullBlkModule,
|
||||||
name: "rnull_mod",
|
name: "rnull_mod",
|
||||||
author: "Andreas Hindborg",
|
authors: ["Andreas Hindborg"],
|
||||||
description: "Rust implementation of the C null block driver",
|
description: "Rust implementation of the C null block driver",
|
||||||
license: "GPL v2",
|
license: "GPL v2",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
DeviceId::new_with_driver::<PhyAX88796B>()
|
DeviceId::new_with_driver::<PhyAX88796B>()
|
||||||
],
|
],
|
||||||
name: "rust_asix_phy",
|
name: "rust_asix_phy",
|
||||||
author: "FUJITA Tomonori <fujita.tomonori@gmail.com>",
|
authors: ["FUJITA Tomonori <fujita.tomonori@gmail.com>"],
|
||||||
description: "Rust Asix PHYs driver",
|
description: "Rust Asix PHYs driver",
|
||||||
license: "GPL",
|
license: "GPL",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
phy::DeviceId::new_with_driver::<PhyQT2025>(),
|
phy::DeviceId::new_with_driver::<PhyQT2025>(),
|
||||||
],
|
],
|
||||||
name: "qt2025_phy",
|
name: "qt2025_phy",
|
||||||
author: "FUJITA Tomonori <fujita.tomonori@gmail.com>",
|
authors: ["FUJITA Tomonori <fujita.tomonori@gmail.com>"],
|
||||||
description: "AMCC QT2025 PHY driver",
|
description: "AMCC QT2025 PHY driver",
|
||||||
license: "GPL",
|
license: "GPL",
|
||||||
firmware: ["qt2025-2.0.3.3.fw"],
|
firmware: ["qt2025-2.0.3.3.fw"],
|
||||||
|
|
|
||||||
|
|
@ -790,7 +790,7 @@ const fn as_int(&self) -> u32 {
|
||||||
/// DeviceId::new_with_driver::<PhySample>()
|
/// DeviceId::new_with_driver::<PhySample>()
|
||||||
/// ],
|
/// ],
|
||||||
/// name: "rust_sample_phy",
|
/// name: "rust_sample_phy",
|
||||||
/// author: "Rust for Linux Contributors",
|
/// authors: ["Rust for Linux Contributors"],
|
||||||
/// description: "Rust sample PHYs driver",
|
/// description: "Rust sample PHYs driver",
|
||||||
/// license: "GPL",
|
/// license: "GPL",
|
||||||
/// }
|
/// }
|
||||||
|
|
@ -819,7 +819,7 @@ const fn as_int(&self) -> u32 {
|
||||||
/// module! {
|
/// module! {
|
||||||
/// type: Module,
|
/// type: Module,
|
||||||
/// name: "rust_sample_phy",
|
/// name: "rust_sample_phy",
|
||||||
/// author: "Rust for Linux Contributors",
|
/// authors: ["Rust for Linux Contributors"],
|
||||||
/// description: "Rust sample PHYs driver",
|
/// description: "Rust sample PHYs driver",
|
||||||
/// license: "GPL",
|
/// license: "GPL",
|
||||||
/// }
|
/// }
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ extern "C" fn remove_callback(pdev: *mut bindings::pci_dev) {
|
||||||
/// kernel::module_pci_driver! {
|
/// kernel::module_pci_driver! {
|
||||||
/// type: MyDriver,
|
/// type: MyDriver,
|
||||||
/// name: "Module name",
|
/// name: "Module name",
|
||||||
/// author: "Author name",
|
/// authors: ["Author name"],
|
||||||
/// description: "Description",
|
/// description: "Description",
|
||||||
/// license: "GPL v2",
|
/// license: "GPL v2",
|
||||||
/// }
|
/// }
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ fn of_id_table() -> Option<of::IdTable<Self::IdInfo>> {
|
||||||
/// kernel::module_platform_driver! {
|
/// kernel::module_platform_driver! {
|
||||||
/// type: MyDriver,
|
/// type: MyDriver,
|
||||||
/// name: "Module name",
|
/// name: "Module name",
|
||||||
/// author: "Author name",
|
/// authors: ["Author name"],
|
||||||
/// description: "Description",
|
/// description: "Description",
|
||||||
/// license: "GPL v2",
|
/// license: "GPL v2",
|
||||||
/// }
|
/// }
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
/// module!{
|
/// module!{
|
||||||
/// type: MyModule,
|
/// type: MyModule,
|
||||||
/// name: "my_kernel_module",
|
/// name: "my_kernel_module",
|
||||||
/// author: "Rust for Linux Contributors",
|
/// authors: ["Rust for Linux Contributors"],
|
||||||
/// description: "My very own kernel module!",
|
/// description: "My very own kernel module!",
|
||||||
/// license: "GPL",
|
/// license: "GPL",
|
||||||
/// alias: ["alternate_module_name"],
|
/// alias: ["alternate_module_name"],
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
/// module!{
|
/// module!{
|
||||||
/// type: MyDeviceDriverModule,
|
/// type: MyDeviceDriverModule,
|
||||||
/// name: "my_device_driver_module",
|
/// name: "my_device_driver_module",
|
||||||
/// author: "Rust for Linux Contributors",
|
/// authors: ["Rust for Linux Contributors"],
|
||||||
/// description: "My device driver requires firmware",
|
/// description: "My device driver requires firmware",
|
||||||
/// license: "GPL",
|
/// license: "GPL",
|
||||||
/// firmware: ["my_device_firmware1.bin", "my_device_firmware2.bin"],
|
/// firmware: ["my_device_firmware1.bin", "my_device_firmware2.bin"],
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
/// # Supported argument types
|
/// # Supported argument types
|
||||||
/// - `type`: type which implements the [`Module`] trait (required).
|
/// - `type`: type which implements the [`Module`] trait (required).
|
||||||
/// - `name`: ASCII string literal of the name of the kernel module (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.
|
/// - `description`: string literal of the description of the kernel module.
|
||||||
/// - `license`: ASCII string literal of the license of the kernel module (required).
|
/// - `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.
|
/// - `alias`: array of ASCII string literals of the alias names of the kernel module.
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ struct ModuleInfo {
|
||||||
license: String,
|
license: String,
|
||||||
name: String,
|
name: String,
|
||||||
author: Option<String>,
|
author: Option<String>,
|
||||||
|
authors: Option<Vec<String>>,
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
alias: Option<Vec<String>>,
|
alias: Option<Vec<String>>,
|
||||||
firmware: Option<Vec<String>>,
|
firmware: Option<Vec<String>>,
|
||||||
|
|
@ -108,6 +109,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self {
|
||||||
"type",
|
"type",
|
||||||
"name",
|
"name",
|
||||||
"author",
|
"author",
|
||||||
|
"authors",
|
||||||
"description",
|
"description",
|
||||||
"license",
|
"license",
|
||||||
"alias",
|
"alias",
|
||||||
|
|
@ -136,6 +138,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self {
|
||||||
"type" => info.type_ = expect_ident(it),
|
"type" => info.type_ = expect_ident(it),
|
||||||
"name" => info.name = expect_string_ascii(it),
|
"name" => info.name = expect_string_ascii(it),
|
||||||
"author" => info.author = Some(expect_string(it)),
|
"author" => info.author = Some(expect_string(it)),
|
||||||
|
"authors" => info.authors = Some(expect_string_array(it)),
|
||||||
"description" => info.description = Some(expect_string(it)),
|
"description" => info.description = Some(expect_string(it)),
|
||||||
"license" => info.license = expect_string_ascii(it),
|
"license" => info.license = expect_string_ascii(it),
|
||||||
"alias" => info.alias = Some(expect_string_array(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 {
|
if let Some(author) = info.author {
|
||||||
modinfo.emit("author", &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 {
|
if let Some(description) = info.description {
|
||||||
modinfo.emit("description", &description);
|
modinfo.emit("description", &description);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
module! {
|
module! {
|
||||||
type: SampleModule,
|
type: SampleModule,
|
||||||
name: "rust_faux_driver",
|
name: "rust_faux_driver",
|
||||||
author: "Lyude Paul",
|
authors: ["Lyude Paul"],
|
||||||
description: "Rust faux device sample",
|
description: "Rust faux device sample",
|
||||||
license: "GPL",
|
license: "GPL",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ fn drop(&mut self) {
|
||||||
kernel::module_pci_driver! {
|
kernel::module_pci_driver! {
|
||||||
type: SampleDriver,
|
type: SampleDriver,
|
||||||
name: "rust_driver_pci",
|
name: "rust_driver_pci",
|
||||||
author: "Danilo Krummrich",
|
authors: ["Danilo Krummrich"],
|
||||||
description: "Rust PCI driver",
|
description: "Rust PCI driver",
|
||||||
license: "GPL v2",
|
license: "GPL v2",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ fn drop(&mut self) {
|
||||||
kernel::module_platform_driver! {
|
kernel::module_platform_driver! {
|
||||||
type: SampleDriver,
|
type: SampleDriver,
|
||||||
name: "rust_driver_platform",
|
name: "rust_driver_platform",
|
||||||
author: "Danilo Krummrich",
|
authors: ["Danilo Krummrich"],
|
||||||
description: "Rust Platform driver",
|
description: "Rust Platform driver",
|
||||||
license: "GPL v2",
|
license: "GPL v2",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
module! {
|
module! {
|
||||||
type: RustMinimal,
|
type: RustMinimal,
|
||||||
name: "rust_minimal",
|
name: "rust_minimal",
|
||||||
author: "Rust for Linux Contributors",
|
authors: ["Rust for Linux Contributors"],
|
||||||
description: "Rust minimal sample",
|
description: "Rust minimal sample",
|
||||||
license: "GPL",
|
license: "GPL",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@
|
||||||
module! {
|
module! {
|
||||||
type: RustMiscDeviceModule,
|
type: RustMiscDeviceModule,
|
||||||
name: "rust_misc_device",
|
name: "rust_misc_device",
|
||||||
author: "Lee Jones",
|
authors: ["Lee Jones"],
|
||||||
description: "Rust misc device sample",
|
description: "Rust misc device sample",
|
||||||
license: "GPL",
|
license: "GPL",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
module! {
|
module! {
|
||||||
type: RustPrint,
|
type: RustPrint,
|
||||||
name: "rust_print",
|
name: "rust_print",
|
||||||
author: "Rust for Linux Contributors",
|
authors: ["Rust for Linux Contributors"],
|
||||||
description: "Rust printing macros sample",
|
description: "Rust printing macros sample",
|
||||||
license: "GPL",
|
license: "GPL",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue