Re: [PATCH v2] rust: module_param: return value by copy from `value`

From: Gary Guo

Date: Mon Jun 01 2026 - 16:16:56 EST


On Mon Jun 1, 2026 at 11:17 AM BST, Andreas Hindborg wrote:
> For `Copy` parameter types it is more ergonomic to retrieve the
> parameter value by copy than through a shared reference. Change
> `ModuleParamAccess::value` to return `T` by copy when `T: Copy`,
> and rename the previous reference-returning accessor to
> `value_ref`. Update the in-tree caller in `rust_minimal`.
>
> Suggested-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>

Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>

> ---
> This change was suggested during review of the rust null block series [1].
>
> [1] https://lore.kernel.org/r/abfe2LbhLzXiGCkA@xxxxxxxxxx
> ---
> Changes in v2:
> - Move `value` into existing impl block (Gary).
> - Add inline attributes (Sashiko).
> - Link to v1: https://msgid.link/20260529-modules-value-ref-v1-1-a0df7e9e6f2d@xxxxxxxxxx
> ---
> rust/kernel/module_param.rs | 18 +++++++++++++++++-
> samples/rust/rust_minimal.rs | 2 +-
> 2 files changed, 18 insertions(+), 2 deletions(-)