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: driver core: remove drvdata() and driver_type Date: Tue, 28 Apr 2026 13:51:40 +1000 Message-ID: In-Reply-To: <20260427221002.2143861-3-dakr@kernel.org> References: <20260427221002.2143861-1-dakr@kernel.org> <20260427221002.2143861-3-dakr@kernel.org> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review This is a clean removal patch. All the pieces fit together: **C-side removal** (`drivers/base/base.h`): The `struct driver_type` and the `driver_type` field in `struct device_priv= ate` are cleanly removed behind `#ifdef CONFIG_RUST`. This shrinks `struct = device_private` by 16 bytes for Rust-enabled kernels. **Rust-side removal** (`rust/kernel/device.rs`): Removed items: - `set_type_id()` =E2=80=94 was called from `set_drvdata()` - `match_type_id()` =E2=80=94 was called from `drvdata()` - `drvdata()` =E2=80=94 the public type-checked accessor Retained items (correctly): - `set_drvdata()` =E2=80=94 still used internally by bus `probe_callback`s - `drvdata_borrow()` / `drvdata_unchecked()` =E2=80=94 still used internall= y by bus `remove_callback`s - `drvdata_obtain()` =E2=80=94 still used for taking ownership during unbind The `static_assert!` comparing `size_of::()` to `siz= e_of::()` is correctly removed since `struct driver_type` no longer= exists. `set_drvdata` no longer calls `set_type_id`: ```rust pub fn set_drvdata(&self, data: impl PinInit) -> Resu= lt { let data =3D KBox::pin_init(data, GFP_KERNEL)?; unsafe { bindings::dev_set_drvdata(self.as_raw(), data.into_foreign().c= ast()) }; Ok(()) } ``` This is safe because the remaining callers of `drvdata_borrow`/`drvdata_unc= hecked` are all `unsafe` internal methods where the type `T` is known stati= cally by the bus abstraction code =E2=80=94 no runtime type check is needed. **Summary**: Both patches are correct. The series achieves a genuine simpli= fication: lifetime constraints that were previously upheld by convention (d= rvdata must outlive all callers) are now enforced structurally (registratio= n data is owned by `Registration`, and `Registration::drop` unbinds the chi= ld before freeing the data). --- Generated by Claude Code Patch Reviewer