]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rust: init: add `write_[pin_]init` functions
authorBenno Lossin <benno.lossin@proton.me>
Mon, 19 Aug 2024 11:24:39 +0000 (11:24 +0000)
committerMiguel Ojeda <ojeda@kernel.org>
Wed, 21 Aug 2024 22:16:16 +0000 (00:16 +0200)
commit6d1c22d0ace31d096b0dab5318c6a0d3219d6456
treea26b0a491e2b3265b3a59960ba786c7043fc6320
parent01db99b272318da75a1aa5a81f75adb9d32f676e
rust: init: add `write_[pin_]init` functions

Sometimes it is necessary to split allocation and initialization into
two steps. One such situation is when reusing existing allocations
obtained via `Box::drop_contents`. See [1] for an example.

In order to support this use case add `write_[pin_]init` functions to the
pin-init API. These functions operate on already allocated smart
pointers that wrap `MaybeUninit<T>`.

Link: https://lore.kernel.org/rust-for-linux/f026532f-8594-4f18-9aa5-57ad3f5bc592@proton.me/
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/r/20240819112415.99810-2-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/init.rs
rust/kernel/prelude.rs