From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: samples: rust: rust_driver_pci: use HRT lifetime for Bar Date: Tue, 26 May 2026 06:47:04 +1000 Message-ID: In-Reply-To: <20260525202921.124698-21-dakr@kernel.org> References: <20260525202921.124698-1-dakr@kernel.org> <20260525202921.124698-21-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 This is the showcase patch. The before/after is dramatic: ```rust -#[pin_data(PinnedDrop)] -struct SampleDriver { - pdev: ARef, - #[pin] - bar: Devres, +struct SampleDriverData<'bound> { + pdev: &'bound pci::Device, + bar: Bar0<'bound>, index: TestIndex, } +struct SampleDriver; ``` The probe function becomes much simpler -- no `pin_init_scope`, no `try_pin_init!`, no `bar.access()` checks: ```rust + let bar = pdev.iomap_region_sized::<{ regs::END }>(0, c"rust_driver_pci")?; + Ok(SampleDriverData { pdev, bar, index: *info }) ``` And unbind can access the bar directly without fallible access: ```rust - fn unbind(pdev: &pci::Device>, this: Pin<&Self>) { - if let Ok(bar) = this.bar.access(pdev.as_ref()) { - bar.write_reg(regs::TEST::zeroed().with_index(this.index)); - } + fn unbind<'bound>(_pdev: &'bound pci::Device>, this: Pin<&Self::Data<'bound>>) { + this.bar.write_reg(regs::TEST::zeroed().with_index(this.index)); ``` `PinnedDrop` becomes a plain `Drop`. Excellent demonstration of the ergonomic improvement. --- Generated by Claude Code Patch Reviewer