]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: module: introduce `authors` key
authorGuilherme Giacomo Simoes <trintaeoitogc@gmail.com>
Sun, 9 Mar 2025 17:57:11 +0000 (14:57 -0300)
committerMiguel Ojeda <ojeda@kernel.org>
Mon, 10 Mar 2025 14:12:17 +0000 (15:12 +0100)
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>
14 files changed:
drivers/block/rnull.rs
drivers/net/phy/ax88796b_rust.rs
drivers/net/phy/qt2025.rs
rust/kernel/net/phy.rs
rust/kernel/pci.rs
rust/kernel/platform.rs
rust/macros/lib.rs
rust/macros/module.rs
samples/rust/rust_driver_faux.rs
samples/rust/rust_driver_pci.rs
samples/rust/rust_driver_platform.rs
samples/rust/rust_minimal.rs
samples/rust/rust_misc_device.rs
samples/rust/rust_print_main.rs

index ddf3629d88940f3095aae5f08eb42869410e5cc5..d07e76ae2c13f41e245f49187fcf4f513cbcece1 100644 (file)
@@ -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",
 }
index 8c7eb009d9fc0f462feb14f4f3d42d303cc4757f..bc73ebccc2aacaa527be4491d47465ce6c884c1f 100644 (file)
@@ -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",
 }
index 1ab065798175b4f54c5f2fd6c871ba2942c48bf1..520daeb42089585f82d5f25599c305e24d32560d 100644 (file)
@@ -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"],
index bb654a28dab36f89d977076b15919c7be9bff036..a59469c785e339e62ad972717898cd567598c13b 100644 (file)
@@ -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",
 /// }
index 4c98b5b9aa1e92d5a363172a5ae54510769a40f1..f7b2743828ae8e82bfb24d9463446efb4a23002e 100644 (file)
@@ -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",
 /// }
index 50e6b0421813224f39ce9fdf592a6cfeffe4e150..1297f5292ba9b7ca9784f84979efbeccb0768bd3 100644 (file)
@@ -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",
 /// }
index a52443a3dbb9ad0cdbec4256276e7ac901c0a875..8c7b786377eead7d4be08d8ffe1e791086a83762 100644 (file)
@@ -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.
index cdf94f4982dfc109ac5c7e9001897555de19d67e..42ed16c48b37b26b2e0eecc0fbee74a3d6d9cc4f 100644 (file)
@@ -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);
     }
index 048c6cb98b29a14c7350aae8c4d602c79ce46924..378bab4b587d354cc08025486aee14d346cc00df 100644 (file)
@@ -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",
 }
index 1fb6e44f33951c521c8b086a7a3a012af911cf26..364a0660a7437eb11400e0a062c4d7f24604987b 100644 (file)
@@ -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",
 }
index 8120609e29402b62294384cc3780694405c9c7c6..f7a0f1b29d1df67c3ee048221edac86c9407f6ac 100644 (file)
@@ -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",
 }
index 4aaf117bf8e3c0cc77e188b1ad0708e3650a6654..1fc7a1be6b6d750a1d992ee767b7e8ad89fb9fa3 100644 (file)
@@ -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",
 }
index 40ad7266c2252e5c0b4e91e501ef9ada2eda3b16..d3785e7c03306da883571890c4e79340d2a7824b 100644 (file)
@@ -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",
 }
index 7e8af5f176a33925881c7d65b34c823028b7b93b..8ea95e8c2f3647650577c4e9dab853e0e3a8bf20 100644 (file)
@@ -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",
 }