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

Petr Pavlu <[email protected]> Fri, 10 Jul 2026 16:10:28 +0200
Newsgroups org.kernel.vger.linux-modules,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
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 <[email protected]>

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/[email protected]/ [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/[email protected]/

-- 
Thanks,
Petr