aboutsummaryrefslogtreecommitdiffstats
path: root/rust/kernel/module_param.rs
AgeCommit message (Collapse)AuthorFilesLines
2026-08-06rust: module_param: support bool parametersWenzhao Liao1-1/+8
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`. 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@kernel.org/ [1] Assisted-by: Codex:GPT-5 Signed-off-by: Wenzhao Liao <wenzhaoliao@ruc.edu.cn> Tested-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://lore.kernel.org/linux-modules/20260411130254.3510128-1-wenzhaoliao@ruc.edu.cn/ [ppavlu: add motivation to the commit message and rebase the patch] Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
2026-08-06rust: module_param: return value by copy from `value`Andreas Hindborg1-1/+17
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@google.com> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
2026-06-04rust: module_param: add missing newline to pr_warn_onceKenny Glowner1-1/+1
Add a trailing newline ('\n') to the pr_warn_once! call in set_param to ensure the kernel ring buffer flushes the message correctly and prevents log line smearing. Signed-off-by: Kenny Glowner <SisyphusCode0311@gmail.com> Suggested-by: Miguel Ojeda <ojeda@kernel.org> Link: https://github.com/Rust-for-Linux/linux/issues/1139 [Sami: Updated the commit message as we use pr_warn_once now.] Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2026-05-27rust: module_param: use `pr_warn_once!` for null pointer warningAndreas Hindborg1-2/+1
Replace `pr_warn!` and the accompanying TODO with `pr_warn_once!`, now that the macro is available. [ Note: Adarsh Das independently authored an identical patch on the rust-for-linux list, but it missed the modules tree. ] Suggested-by: Adarsh Das <adarshdas950@gmail.com> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Aaron Tomlin <atomlin@atomlin.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Daniel Gomez <da.gomez@samsung.com> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2025-12-06Merge tag 'modules-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linuxLinus Torvalds1-0/+182
Pull module updates from Daniel Gomez: "Rust module parameter support: - Add Rust module parameter support, enabling Rust kernel modules to declare and use module parameters. The rust_minimal sample module demonstrates this, and the rust null block driver will be the first to use it in the next cycle. This also adds the Rust module files under the modules subsystem as agreed between the Rust and modules maintainers. Hardening: - Add compile-time check for embedded NUL characters in MODULE_*() macros. This module metadata was once used (and maybe still) to bypass license enforcement (LWN article from 2003): https://lwn.net/Articles/82305/ [1] MAINTAINERS: - Add Aaron Tomlin as reviewer for the Modules subsystem" * tag 'modules-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux: MAINTAINERS: Add myself as reviewer for module support module: Add compile-time check for embedded NUL characters media: radio: si470x: Fix DRIVER_AUTHOR macro definition media: dvb-usb-v2: lmedm04: Fix firmware macro definitions modules: add rust modules files to MAINTAINERS rust: samples: add a module parameter to the rust_minimal sample rust: module: update the module macro with module parameter support rust: module: use a reference in macros::module::module rust: introduce module_param module rust: str: add radix prefixed integer parsing functions rust: sync: add `SetOnce`
2025-11-03rust: introduce module_param moduleAndreas Hindborg1-0/+181
Add types and traits for interfacing the C moduleparam API. Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Tested-by: Daniel Gomez <da.gomez@samsung.com> Signed-off-by: Daniel Gomez <da.gomez@kernel.org>