Skip to content

Commit f6b88f0

Browse files
author
Andreas Hindborg
committed
LIST: [PATCH v17 6/7] rust: samples: add a module parameter to the rust_minimal sample
Showcase the rust module parameter support by adding a module parameter to the `rust_minimal` sample. Reviewed-by: Benno Lossin <lossin@kernel.org> Link: Rust-for-Linux#7 [1] Link: Rust-for-Linux#82 [2] Link: Rust-for-Linux#87 [3] Link: Rust-for-Linux#11 [4] Link: https://lore.kernel.org/r/20250711-module-params-v3-v17-6-cf9b10d4923d@kernel.org Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
1 parent a1a1125 commit f6b88f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

samples/rust/rust_minimal.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ module! {
1010
authors: ["Rust for Linux Contributors"],
1111
description: "Rust minimal sample",
1212
license: "GPL",
13+
params: {
14+
test_parameter: i64 {
15+
default: 1,
16+
description: "This parameter has a default of 1",
17+
},
18+
},
1319
}
1420

1521
struct RustMinimal {
@@ -20,6 +26,10 @@ impl kernel::Module for RustMinimal {
2026
fn init(_module: &'static ThisModule) -> Result<Self> {
2127
pr_info!("Rust minimal sample (init)\n");
2228
pr_info!("Am I built-in? {}\n", !cfg!(MODULE));
29+
pr_info!(
30+
"test_parameter: {}\n",
31+
*module_parameters::test_parameter.value()
32+
);
2333

2434
let mut numbers = KVec::new();
2535
numbers.push(72, GFP_KERNEL)?;

0 commit comments

Comments
 (0)