rust: types: add `Opaque::ffi_init`
authorBenno Lossin <benno.lossin@proton.me>
Sat, 8 Apr 2023 12:26:22 +0000 (12:26 +0000)
committerMiguel Ojeda <ojeda@kernel.org>
Wed, 12 Apr 2023 16:41:05 +0000 (18:41 +0200)
commit692e8935e23efab6c5d5fc4b003816b33c8082f7
tree18fe62f03bfdc6475f4e0ab63eb952cc4d98aaa3
parent8586f1acd314a47d68d189331606ca235a05b972
rust: types: add `Opaque::ffi_init`

This function allows to easily initialize `Opaque` with the pin-init
API. `Opaque::ffi_init` takes a closure and returns a pin-initializer.
This pin-initiailizer calls the given closure with a pointer to the
inner `T`.

Co-developed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20230408122429.1103522-14-y86-dev@protonmail.com
[ Fixed typo. ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/init.rs
rust/kernel/types.rs