rust: pin-init: add references to previously initialized fields

After initializing a field in an initializer macro, create a variable
holding a reference that points at that field. The type is either
`Pin<&mut T>` or `&mut T` depending on the field's structural pinning
kind.

[ Applied fixes to devres and rust_driver_pci sample - Benno]
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Benno Lossin <lossin@kernel.org>
This commit is contained in:
Benno Lossin
2025-09-05 16:00:46 +02:00
parent 1fa516794f
commit 42415d163e
3 changed files with 118 additions and 39 deletions
+1 -1
View File
@@ -78,8 +78,8 @@ impl pci::Driver for SampleDriver {
let drvdata = KBox::pin_init(
try_pin_init!(Self {
pdev: pdev.into(),
bar <- pdev.iomap_region_sized::<{ Regs::END }>(0, c_str!("rust_driver_pci")),
pdev: pdev.into(),
index: *info,
}),
GFP_KERNEL,