Re: [PATCH 1/1] rust: module_param: support bool parameters

From: Petr Pavlu

Date: Fri Jul 10 2026 - 10:22:58 EST


On 4/11/26 3:02 PM, Wenzhao Liao wrote:
> Add support for parsing boolean module parameters in the Rust
> module! macro.
>
> Currently, only integer types are supported by the `module_param!`
> macros. This patch implements the `ModuleParam` trait for `bool`
> by delegating the string parsing to the existing C implementation
> via `kstrtobool_bytes()`. It also wires up `PARAM_OPS_BOOL` so that
> the Rust parameter system correctly links to the C `param_ops_bool`
> structure.
>
> For demonstration and verification, a boolean parameter is added
> to `samples/rust/rust_minimal.rs`.
>
> Assisted-by: Codex:GPT-5
> Signed-off-by: Wenzhao Liao <wenzhaoliao@xxxxxxxxxx>

I've queued the patch on modules-next for v7.3-rc1, with the following
minor changes:

* Added a short description of the motivation to the commit message:

Support for boolean parameters will initially be used by the Rust
null block driver [1].

Link: https://lore.kernel.org/all/20260609-rnull-v6-19-rc5-send-v2-4-82c7404542e2@xxxxxxxxxx/ [1]

* Rebased the patch on top of '[PATCH v2] rust: module_param: return
value by copy from `value`' [1], which required removing the
dereference from '*module_parameters::test_bool_parameter.value()' in
samples/rust/rust_minimal.rs.

[1] https://lore.kernel.org/linux-modules/20260601-modules-value-ref-v2-1-12ebbf0510c9@xxxxxxxxxx/

--
Thanks,
Petr