Skip to content

Commit 71eeae1

Browse files
Andreas Hindborgjannau
authored andcommitted
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> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
1 parent a2b4c37 commit 71eeae1

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

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)