rust: add `Module::as_ptr`
authorAlice Ryhl <aliceryhl@google.com>
Mon, 26 Feb 2024 09:44:02 +0000 (09:44 +0000)
committerMiguel Ojeda <ojeda@kernel.org>
Fri, 29 Mar 2024 17:04:32 +0000 (18:04 +0100)
commitd0f0241d8d8b71b3f5fdf0592e6e6b0e44d5d5c0
treefd5226dca6c4967d8a100479237cc83670536972
parent4cece764965020c22cff7665b18a012006359095
rust: add `Module::as_ptr`

This allows you to get a raw pointer to THIS_MODULE for use in unsafe
code. The Rust Binder RFC uses it when defining fops for the binderfs
component [1].

This doesn't really need to go in now - it could go in together with
Rust Binder like how it is sent in the Rust Binder RFC. However, the
upcoming 1.77.0 release of the Rust compiler introduces a new warning,
and applying this patch now will silence that warning. That allows us to
avoid adding the #[allow(dead_code)] annotation seen in [2].

Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-2-08ba9197f637@google.com/
Link: https://lore.kernel.org/all/20240217002717.57507-1-ojeda@kernel.org/
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Trevor Gross <tmgross@umich.edu>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20240226-module-as-ptr-v1-1-83bc89213113@google.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/lib.rs