mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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>
		
	
			
		
			
				
	
	
		
			38 lines
		
	
	
	
		
			881 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			881 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
// SPDX-License-Identifier: GPL-2.0
 | 
						|
 | 
						|
//! Rust minimal sample.
 | 
						|
 | 
						|
use kernel::prelude::*;
 | 
						|
 | 
						|
module! {
 | 
						|
    type: RustMinimal,
 | 
						|
    name: "rust_minimal",
 | 
						|
    authors: ["Rust for Linux Contributors"],
 | 
						|
    description: "Rust minimal sample",
 | 
						|
    license: "GPL",
 | 
						|
}
 | 
						|
 | 
						|
struct RustMinimal {
 | 
						|
    numbers: KVec<i32>,
 | 
						|
}
 | 
						|
 | 
						|
impl kernel::Module for RustMinimal {
 | 
						|
    fn init(_module: &'static ThisModule) -> Result<Self> {
 | 
						|
        pr_info!("Rust minimal sample (init)\n");
 | 
						|
        pr_info!("Am I built-in? {}\n", !cfg!(MODULE));
 | 
						|
 | 
						|
        let mut numbers = KVec::new();
 | 
						|
        numbers.push(72, GFP_KERNEL)?;
 | 
						|
        numbers.push(108, GFP_KERNEL)?;
 | 
						|
        numbers.push(200, GFP_KERNEL)?;
 | 
						|
 | 
						|
        Ok(RustMinimal { numbers })
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
impl Drop for RustMinimal {
 | 
						|
    fn drop(&mut self) {
 | 
						|
        pr_info!("My numbers are {:?}\n", self.numbers);
 | 
						|
        pr_info!("Rust minimal sample (exit)\n");
 | 
						|
    }
 | 
						|
}
 |