3
0
Fork 0
forked from mirrors/linux
kernel/samples/rust/rust_driver_faux.rs
Guilherme Giacomo Simoes 38559da6af 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>
2025-03-10 15:12:17 +01:00

29 lines
669 B
Rust

// SPDX-License-Identifier: GPL-2.0-only
//! Rust faux device sample.
use kernel::{c_str, faux, prelude::*, Module};
module! {
type: SampleModule,
name: "rust_faux_driver",
authors: ["Lyude Paul"],
description: "Rust faux device sample",
license: "GPL",
}
struct SampleModule {
_reg: faux::Registration,
}
impl Module for SampleModule {
fn init(_module: &'static ThisModule) -> Result<Self> {
pr_info!("Initialising Rust Faux Device Sample\n");
let reg = faux::Registration::new(c_str!("rust-faux-sample-device"))?;
dev_info!(reg.as_ref(), "Hello from faux device!\n");
Ok(Self { _reg: reg })
}
}