diff --git a/drivers/android/rust_binder.rs b/drivers/android/rust_binder.rs index f6432cac0f0a19..714e81e270029d 100644 --- a/drivers/android/rust_binder.rs +++ b/drivers/android/rust_binder.rs @@ -28,7 +28,7 @@ use {context::Context, thread::Thread}; module! { type: BinderModule, name: "rust_binder", - author: "Wedson Almeida Filho", + authors: ["Wedson Almeida Filho"], description: "Android Binder", license: "GPL", } diff --git a/drivers/char/hw_random/bcm2835_rng_rust.rs b/drivers/char/hw_random/bcm2835_rng_rust.rs index 661ec362a0f032..016ec5ae25aa02 100644 --- a/drivers/char/hw_random/bcm2835_rng_rust.rs +++ b/drivers/char/hw_random/bcm2835_rng_rust.rs @@ -10,7 +10,7 @@ use kernel::{ module_platform_driver! { type: RngDriver, name: "bcm2835_rng_rust", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "BCM2835 Random Number Generator (RNG) driver", license: "GPL v2", } diff --git a/rust/macros/helpers.rs b/rust/macros/helpers.rs index 8b5f9bc414d7ae..9a5bbf40bb9878 100644 --- a/rust/macros/helpers.rs +++ b/rust/macros/helpers.rs @@ -10,6 +10,14 @@ pub(crate) fn try_ident(it: &mut token_stream::IntoIter) -> Option<String> { } } +pub(crate) fn try_punct(it: &mut token_stream::IntoIter) -> Option<char> { + if let Some(TokenTree::Punct(punct)) = it.next() { + Some(punct.as_char()) + } else { + None + } +} + pub(crate) fn try_literal(it: &mut token_stream::IntoIter) -> Option<String> { if let Some(TokenTree::Literal(literal)) = it.next() { Some(literal.to_string()) diff --git a/rust/macros/module.rs b/rust/macros/module.rs index 6001fd692469be..2f21bccb4cf89f 100644 --- a/rust/macros/module.rs +++ b/rust/macros/module.rs @@ -215,7 +215,7 @@ struct ModuleInfo { type_: String, license: String, name: String, - author: Option<String>, + authors: Option<Vec<String>>, description: Option<String>, alias: Option<String>, params: Option<Group>, @@ -228,7 +228,7 @@ impl ModuleInfo { const EXPECTED_KEYS: &[&str] = &[ "type", "name", - "author", + "authors", "description", "license", "alias", @@ -257,7 +257,7 @@ impl ModuleInfo { match key.as_str() { "type" => info.type_ = expect_ident(it), "name" => info.name = expect_string_ascii(it), - "author" => info.author = Some(expect_string(it)), + "authors" => info.authors = Some(Self::parse_authors(it)), "description" => info.description = Some(expect_string(it)), "license" => info.license = expect_string_ascii(it), "alias" => info.alias = Some(expect_string_ascii(it)), @@ -300,6 +300,26 @@ impl ModuleInfo { info } + + /// Parse ["First", "Second"] into Some(vec!["First", "Second"]) + fn parse_authors(it: &mut token_stream::IntoIter) -> Vec<String> { + let mut authors: Vec<String> = vec![]; + let group = expect_group(it); + assert_eq!(group.delimiter(), Delimiter::Bracket); + let mut stream = group.stream().into_iter(); + loop { + let author = expect_string(&mut stream); + authors.push(author); + if let Some(punct) = try_punct(&mut stream) { + assert_eq!(punct, ','); + } else { + assert!(stream.next().is_none()); + break; + } + } + + authors + } } pub(crate) fn module(ts: TokenStream) -> TokenStream { @@ -308,8 +328,10 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream { let info = ModuleInfo::parse(&mut it); let mut modinfo = ModInfoBuilder::new(info.name.as_ref()); - 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); diff --git a/samples/rust/rust_chrdev.rs b/samples/rust/rust_chrdev.rs index d87557bff27592..776f2e33045476 100644 --- a/samples/rust/rust_chrdev.rs +++ b/samples/rust/rust_chrdev.rs @@ -8,7 +8,7 @@ use kernel::{chrdev, file}; module! { type: RustChrdev, name: "rust_chrdev", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Rust character device sample", license: "GPL", } diff --git a/samples/rust/rust_echo_server.rs b/samples/rust/rust_echo_server.rs index e57f3dd9cd6462..074422c135e9e5 100644 --- a/samples/rust/rust_echo_server.rs +++ b/samples/rust/rust_echo_server.rs @@ -54,7 +54,7 @@ impl kernel::Module for RustEchoServer { module! { type: RustEchoServer, name: "rust_echo_server", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Rust tcp echo sample", license: "GPL v2", } diff --git a/samples/rust/rust_fs.rs b/samples/rust/rust_fs.rs index 064ead97dd98e3..dd9c83875135f7 100644 --- a/samples/rust/rust_fs.rs +++ b/samples/rust/rust_fs.rs @@ -8,7 +8,7 @@ use kernel::{c_str, fs}; module_fs! { type: RustFs, name: "rust_fs", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], license: "GPL", } diff --git a/samples/rust/rust_minimal.rs b/samples/rust/rust_minimal.rs index 54de32b78cec84..c3c3b2f5bb280b 100644 --- a/samples/rust/rust_minimal.rs +++ b/samples/rust/rust_minimal.rs @@ -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", } diff --git a/samples/rust/rust_miscdev.rs b/samples/rust/rust_miscdev.rs index 24766b2040bdee..dc2c038429c04a 100644 --- a/samples/rust/rust_miscdev.rs +++ b/samples/rust/rust_miscdev.rs @@ -13,7 +13,7 @@ use kernel::{ module! { type: RustMiscdev, name: "rust_miscdev", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Rust miscellaneous device sample", license: "GPL", } diff --git a/samples/rust/rust_module_parameters.rs b/samples/rust/rust_module_parameters.rs index 557cba7b4815d1..7245adbce17e6a 100644 --- a/samples/rust/rust_module_parameters.rs +++ b/samples/rust/rust_module_parameters.rs @@ -7,7 +7,7 @@ use kernel::prelude::*; module! { type: RustModuleParameters, name: "rust_module_parameters", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Rust module parameters sample", license: "GPL", params: { diff --git a/samples/rust/rust_print.rs b/samples/rust/rust_print.rs index f3e06c78d0c38b..08201560c29e15 100644 --- a/samples/rust/rust_print.rs +++ b/samples/rust/rust_print.rs @@ -8,7 +8,7 @@ use kernel::{pr_cont, str::CStr, ThisModule}; module! { type: RustPrint, name: "rust_print", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Rust printing macros sample", license: "GPL", } diff --git a/samples/rust/rust_random.rs b/samples/rust/rust_random.rs index 222d1170a1bcac..b86fd6c5a4bcab 100644 --- a/samples/rust/rust_random.rs +++ b/samples/rust/rust_random.rs @@ -14,7 +14,7 @@ use kernel::{ module_misc_device! { type: RandomFile, name: "rust_random", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Just use /dev/urandom: Now with early-boot safety", license: "GPL", } diff --git a/samples/rust/rust_selftests.rs b/samples/rust/rust_selftests.rs index 91341cbf9e7828..4a7298d24764db 100644 --- a/samples/rust/rust_selftests.rs +++ b/samples/rust/rust_selftests.rs @@ -9,7 +9,7 @@ use kernel::prelude::*; module! { type: RustSelftests, name: "rust_selftests", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Self test cases for Rust", license: "GPL", } diff --git a/samples/rust/rust_semaphore.rs b/samples/rust/rust_semaphore.rs index 37949461403259..a7faf56d195b5d 100644 --- a/samples/rust/rust_semaphore.rs +++ b/samples/rust/rust_semaphore.rs @@ -28,7 +28,7 @@ use kernel::{ module! { type: RustSemaphore, name: "rust_semaphore", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Rust semaphore sample", license: "GPL", } diff --git a/samples/rust/rust_stack_probing.rs b/samples/rust/rust_stack_probing.rs index f44f48cb36e710..f5728764ec6fe2 100644 --- a/samples/rust/rust_stack_probing.rs +++ b/samples/rust/rust_stack_probing.rs @@ -7,7 +7,7 @@ use kernel::prelude::*; module! { type: RustStackProbing, name: "rust_stack_probing", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Rust stack probing sample", license: "GPL", } diff --git a/samples/rust/rust_sync.rs b/samples/rust/rust_sync.rs index 2e0714fcc3d6c9..c2107274add13e 100644 --- a/samples/rust/rust_sync.rs +++ b/samples/rust/rust_sync.rs @@ -11,7 +11,7 @@ use kernel::{ module! { type: RustSync, name: "rust_sync", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Rust synchronisation primitives sample", license: "GPL", }