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_auxiliary: showcase lifetime-bound registration data Date: Tue, 26 May 2026 06:47:04 +1000 Message-ID: In-Reply-To: <20260525202921.124698-25-dakr@kernel.org> References: <20260525202921.124698-1-dakr@kernel.org> <20260525202921.124698-25-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 Makes `Data` lifetime-parameterized with a reference to the parent device: ```rust -struct Data { +struct Data<'bound> { index: u32, + parent: &'bound pci::Device, } ``` Registrations use `ForLt!(Data<'_>)` and the unsafe `new_with_lt()`: ```rust + _reg0: unsafe { + auxiliary::Registration::new_with_lt( + pdev.as_ref(), AUXILIARY_NAME, 0, MODULE_NAME, + Data { index: 0, parent: pdev }, + )? + }, ``` The SAFETY comment explains that `ParentData` is the driver's private data dropped on unbind, so `mem::forget()` is never called. In `connect()`, the parent device is retrieved from registration data instead of casting through `adev.parent()`: ```rust - let dev = adev.parent(); - let pdev: &pci::Device = dev.try_into()?; - let data = adev.registration_data::()?; + let data = adev.registration_data::)>()?; + let pdev = data.parent; ``` Good demonstration of the HRT registration pattern. The `#[allow(clippy::type_complexity)]` on `ParentData` fields is appropriate given the `ForLt!(...)` types. --- Generated by Claude Code Patch Reviewer