]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rust: samples: add a module parameter to the rust_minimal sample
authorAndreas Hindborg <a.hindborg@kernel.org>
Wed, 24 Sep 2025 12:39:29 +0000 (14:39 +0200)
committerDaniel Gomez <da.gomez@kernel.org>
Mon, 3 Nov 2025 13:42:34 +0000 (14:42 +0100)
Showcase the rust module parameter support by adding a module parameter to
the `rust_minimal` sample.

Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
Tested-by: Daniel Gomez <da.gomez@samsung.com>
Signed-off-by: Daniel Gomez <da.gomez@kernel.org>
samples/rust/rust_minimal.rs

index 1fc7a1be6b6d750a1d992ee767b7e8ad89fb9fa3..8eb9583571d726803e4bd7cd8ae79eceee505859 100644 (file)
@@ -10,6 +10,12 @@ module! {
     authors: ["Rust for Linux Contributors"],
     description: "Rust minimal sample",
     license: "GPL",
+    params: {
+        test_parameter: i64 {
+            default: 1,
+            description: "This parameter has a default of 1",
+        },
+    },
 }
 
 struct RustMinimal {
@@ -20,6 +26,10 @@ 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));
+        pr_info!(
+            "test_parameter: {}\n",
+            *module_parameters::test_parameter.value()
+        );
 
         let mut numbers = KVec::new();
         numbers.push(72, GFP_KERNEL)?;