[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DDUWW90NZIDY.2TVA8S0RDSXZJ@kernel.org>
Date: Wed, 29 Oct 2025 16:30:11 +0100
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Alice Ryhl" <aliceryhl@...gle.com>
Cc: <gregkh@...uxfoundation.org>, <rafael@...nel.org>,
 <bhelgaas@...gle.com>, <kwilczynski@...nel.org>,
 <david.m.ertman@...el.com>, <ira.weiny@...el.com>, <leon@...nel.org>,
 <acourbot@...dia.com>, <ojeda@...nel.org>, <alex.gaynor@...il.com>,
 <boqun.feng@...il.com>, <gary@...yguo.net>, <bjorn3_gh@...tonmail.com>,
 <lossin@...nel.org>, <a.hindborg@...nel.org>, <tmgross@...ch.edu>,
 <pcolberg@...hat.com>, <rust-for-linux@...r.kernel.org>,
 <linux-pci@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/8] rust: device: introduce Device::drvdata()
On Wed Oct 29, 2025 at 1:59 PM CET, Alice Ryhl wrote:
> Are you going to open that docs PR to the Rust compiler about the size
> of TypeID that we talked about? :)
Yes, I will -- thanks for the reminder.
> Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>
>
>> +// Compile-time checks.
>> +const _: () = {
>> +    // Assert that we can `read()` / `write()` a `TypeId` instance from / into `struct driver_type`.
>> +    static_assert!(core::mem::size_of::<bindings::driver_type>() == core::mem::size_of::<TypeId>());
>> +};
>
> You don't need the "const _: ()" part. See the definition of
> static_assert! to see why.
Indeed, good catch -- same for the suggestions below.
> Also, I would not require equality. The Rust team did not think that it
> would ever increase in size, but it may decrease.
>
>>  /// The core representation of a device in the kernel's driver model.
>>  ///
>>  /// This structure represents the Rust abstraction for a C `struct device`. A [`Device`] can either
>> @@ -198,12 +204,29 @@ pub unsafe fn as_bound(&self) -> &Device<Bound> {
>>  }
>>  
>>  impl Device<CoreInternal> {
>> +    fn type_id_store<T: 'static>(&self) {
>
> This name isn't great. How about "set_type_id()" instead?
>
> Alice 
Powered by blists - more mailing lists
 
