Skip to content

Commit 38559da

Browse files
GuilhermeGiacomoSimoesojeda
authored andcommitted
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 <[email protected]> Link: Rust-for-Linux#244 Reviewed-by: Charalampos Mitrodimas <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: Guilherme Giacomo Simoes <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Fixed `modinfo` key. Kept `author` field. Reworded message accordingly. Updated my email. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent fc2f191 commit 38559da

File tree

14 files changed

+24
-16
lines changed

14 files changed

+24
-16
lines changed

drivers/block/rnull.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use kernel::{
2727
module! {
2828
type: NullBlkModule,
2929
name: "rnull_mod",
30-
author: "Andreas Hindborg",
30+
authors: ["Andreas Hindborg"],
3131
description: "Rust implementation of the C null block driver",
3232
license: "GPL v2",
3333
}

drivers/net/phy/ax88796b_rust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ kernel::module_phy_driver! {
1919
DeviceId::new_with_driver::<PhyAX88796B>()
2020
],
2121
name: "rust_asix_phy",
22-
author: "FUJITA Tomonori <[email protected]>",
22+
authors: ["FUJITA Tomonori <[email protected]>"],
2323
description: "Rust Asix PHYs driver",
2424
license: "GPL",
2525
}

drivers/net/phy/qt2025.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ kernel::module_phy_driver! {
2626
phy::DeviceId::new_with_driver::<PhyQT2025>(),
2727
],
2828
name: "qt2025_phy",
29-
author: "FUJITA Tomonori <[email protected]>",
29+
authors: ["FUJITA Tomonori <[email protected]>"],
3030
description: "AMCC QT2025 PHY driver",
3131
license: "GPL",
3232
firmware: ["qt2025-2.0.3.3.fw"],

rust/kernel/net/phy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ impl DeviceMask {
790790
/// DeviceId::new_with_driver::<PhySample>()
791791
/// ],
792792
/// name: "rust_sample_phy",
793-
/// author: "Rust for Linux Contributors",
793+
/// authors: ["Rust for Linux Contributors"],
794794
/// description: "Rust sample PHYs driver",
795795
/// license: "GPL",
796796
/// }
@@ -819,7 +819,7 @@ impl DeviceMask {
819819
/// module! {
820820
/// type: Module,
821821
/// name: "rust_sample_phy",
822-
/// author: "Rust for Linux Contributors",
822+
/// authors: ["Rust for Linux Contributors"],
823823
/// description: "Rust sample PHYs driver",
824824
/// license: "GPL",
825825
/// }

rust/kernel/pci.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<T: Driver + 'static> Adapter<T> {
103103
/// kernel::module_pci_driver! {
104104
/// type: MyDriver,
105105
/// name: "Module name",
106-
/// author: "Author name",
106+
/// authors: ["Author name"],
107107
/// description: "Description",
108108
/// license: "GPL v2",
109109
/// }

rust/kernel/platform.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<T: Driver + 'static> driver::Adapter for Adapter<T> {
101101
/// kernel::module_platform_driver! {
102102
/// type: MyDriver,
103103
/// name: "Module name",
104-
/// author: "Author name",
104+
/// authors: ["Author name"],
105105
/// description: "Description",
106106
/// license: "GPL v2",
107107
/// }

rust/macros/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use proc_macro::TokenStream;
3737
/// module!{
3838
/// type: MyModule,
3939
/// name: "my_kernel_module",
40-
/// author: "Rust for Linux Contributors",
40+
/// authors: ["Rust for Linux Contributors"],
4141
/// description: "My very own kernel module!",
4242
/// license: "GPL",
4343
/// alias: ["alternate_module_name"],
@@ -70,7 +70,7 @@ use proc_macro::TokenStream;
7070
/// module!{
7171
/// type: MyDeviceDriverModule,
7272
/// name: "my_device_driver_module",
73-
/// author: "Rust for Linux Contributors",
73+
/// authors: ["Rust for Linux Contributors"],
7474
/// description: "My device driver requires firmware",
7575
/// license: "GPL",
7676
/// firmware: ["my_device_firmware1.bin", "my_device_firmware2.bin"],
@@ -89,7 +89,7 @@ use proc_macro::TokenStream;
8989
/// # Supported argument types
9090
/// - `type`: type which implements the [`Module`] trait (required).
9191
/// - `name`: ASCII string literal of the name of the kernel module (required).
92-
/// - `author`: string literal of the author of the kernel module.
92+
/// - `authors`: array of ASCII string literals of the authors of the kernel module.
9393
/// - `description`: string literal of the description of the kernel module.
9494
/// - `license`: ASCII string literal of the license of the kernel module (required).
9595
/// - `alias`: array of ASCII string literals of the alias names of the kernel module.

rust/macros/module.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ struct ModuleInfo {
9595
license: String,
9696
name: String,
9797
author: Option<String>,
98+
authors: Option<Vec<String>>,
9899
description: Option<String>,
99100
alias: Option<Vec<String>>,
100101
firmware: Option<Vec<String>>,
@@ -108,6 +109,7 @@ impl ModuleInfo {
108109
"type",
109110
"name",
110111
"author",
112+
"authors",
111113
"description",
112114
"license",
113115
"alias",
@@ -136,6 +138,7 @@ impl ModuleInfo {
136138
"type" => info.type_ = expect_ident(it),
137139
"name" => info.name = expect_string_ascii(it),
138140
"author" => info.author = Some(expect_string(it)),
141+
"authors" => info.authors = Some(expect_string_array(it)),
139142
"description" => info.description = Some(expect_string(it)),
140143
"license" => info.license = expect_string_ascii(it),
141144
"alias" => info.alias = Some(expect_string_array(it)),
@@ -186,6 +189,11 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
186189
if let Some(author) = info.author {
187190
modinfo.emit("author", &author);
188191
}
192+
if let Some(authors) = info.authors {
193+
for author in authors {
194+
modinfo.emit("author", &author);
195+
}
196+
}
189197
if let Some(description) = info.description {
190198
modinfo.emit("description", &description);
191199
}

samples/rust/rust_driver_faux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use kernel::{c_str, faux, prelude::*, Module};
77
module! {
88
type: SampleModule,
99
name: "rust_faux_driver",
10-
author: "Lyude Paul",
10+
authors: ["Lyude Paul"],
1111
description: "Rust faux device sample",
1212
license: "GPL",
1313
}

samples/rust/rust_driver_pci.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl Drop for SampleDriver {
104104
kernel::module_pci_driver! {
105105
type: SampleDriver,
106106
name: "rust_driver_pci",
107-
author: "Danilo Krummrich",
107+
authors: ["Danilo Krummrich"],
108108
description: "Rust PCI driver",
109109
license: "GPL v2",
110110
}

samples/rust/rust_driver_platform.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl Drop for SampleDriver {
4343
kernel::module_platform_driver! {
4444
type: SampleDriver,
4545
name: "rust_driver_platform",
46-
author: "Danilo Krummrich",
46+
authors: ["Danilo Krummrich"],
4747
description: "Rust Platform driver",
4848
license: "GPL v2",
4949
}

samples/rust/rust_minimal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use kernel::prelude::*;
77
module! {
88
type: RustMinimal,
99
name: "rust_minimal",
10-
author: "Rust for Linux Contributors",
10+
authors: ["Rust for Linux Contributors"],
1111
description: "Rust minimal sample",
1212
license: "GPL",
1313
}

samples/rust/rust_misc_device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const RUST_MISC_DEV_SET_VALUE: u32 = _IOW::<i32>('|' as u32, 0x82);
116116
module! {
117117
type: RustMiscDeviceModule,
118118
name: "rust_misc_device",
119-
author: "Lee Jones",
119+
authors: ["Lee Jones"],
120120
description: "Rust misc device sample",
121121
license: "GPL",
122122
}

samples/rust/rust_print_main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use kernel::prelude::*;
88
module! {
99
type: RustPrint,
1010
name: "rust_print",
11-
author: "Rust for Linux Contributors",
11+
authors: ["Rust for Linux Contributors"],
1212
description: "Rust printing macros sample",
1313
license: "GPL",
1414
}

0 commit comments

Comments
 (0)