mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
rust: devres: use cast_pin_init instead of manual reimplementation
Remove the manual type-casting which is already available as `cast_pin_init`. Signed-off-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260722-merge-init-v1-2-d4594de76538@garyguo.net Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
1c2c8484b9
commit
a1f1b3b478
|
|
@ -435,11 +435,7 @@ pub unsafe fn new<'a, E>(
|
|||
// SAFETY: The caller guarantees the data is valid for the device's full bound scope.
|
||||
// Lifetimes do not affect layout, so F::Of<'a> and F::Of<'static> have identical
|
||||
// representation; casting the slot pointer is sound.
|
||||
let data = unsafe {
|
||||
pin_init::pin_init_from_closure::<F::Of<'static>, E>(move |slot| {
|
||||
data.__pinned_init(slot.cast())
|
||||
})
|
||||
};
|
||||
let data = unsafe { pin_init::cast_pin_init(data) };
|
||||
|
||||
Ok(Self(Devres::new(dev, data)?))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user