From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: rust: pci: make Bar lifetime-parameterized Date: Tue, 26 May 2026 06:47:03 +1000 Message-ID: In-Reply-To: <20260525202921.124698-19-dakr@kernel.org> References: <20260525202921.124698-1-dakr@kernel.org> <20260525202921.124698-19-dakr@kernel.org> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review Key conversion of `Bar` to `Bar<'a, SIZE>`: ```rust -pub struct Bar { - pdev: ARef, +pub struct Bar<'a, const SIZE: usize = 0> { + pdev: &'a Device, ``` `iomap_region_sized()` changes from returning `impl PinInit>, Error>` to returning `Result>` directly. The `into_devres()` method is added: ```rust + pub fn into_devres(self) -> Result>> { + let bar: Bar<'static, SIZE> = unsafe { core::mem::transmute(self) }; + let pdev = bar.pdev; + Devres::new(pdev.as_ref(), bar) + } ``` The transmute is sound because Devres guarantees the Bar doesn't actually outlive the device -- access is revoked on unbind. The SAFETY comment is adequate. Note: After `transmute`, the code reads `bar.pdev` to get the device reference for `Devres::new`. This is safe because `pdev` was valid before transmute and the `'static` typing doesn't affect the pointer value, but the reference to `bar.pdev` is taken after `bar` has been transmuted to `'static`, which is fine since the device itself outlives this scope. --- Generated by Claude Code Patch Reviewer