[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D8F2YBFHCTFL.3TH1E0TB11EHU@proton.me>
Date: Thu, 13 Mar 2025 10:52:34 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Danilo Krummrich <dakr@...nel.org>
Cc: gregkh@...uxfoundation.org, rafael@...nel.org, bhelgaas@...gle.com, ojeda@...nel.org, alex.gaynor@...il.com, boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com, a.hindborg@...nel.org, aliceryhl@...gle.com, tmgross@...ch.edu, linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH 2/4] rust: device: implement device context marker
On Thu Mar 13, 2025 at 11:41 AM CET, Danilo Krummrich wrote:
> On Thu, Mar 13, 2025 at 10:29:35AM +0000, Benno Lossin wrote:
>> On Thu Mar 13, 2025 at 3:13 AM CET, Danilo Krummrich wrote:
>> > +/// Marker trait for the context of a bus specific device.
>> > +///
>> > +/// Some functions of a bus specific device should only be called from a certain context, i.e. bus
>> > +/// callbacks, such as `probe()`.
>> > +///
>> > +/// This is the marker trait for structures representing the context of a bus specific device.
>> > +pub trait DeviceContext {}
>>
>> I would make this trait sealed. ie:
>>
>> pub trait DeviceContext: private::Sealed {}
>>
>> mod private {
>> pub trait Sealed {}
>>
>> impl Sealed for super::Core {}
>> impl Sealed for super::Normal {}
>> }
>>
>> Since currently a user can create a custom context (it will be useless,
>> but then I think it still is better to give them a compile error).
>
> That is intentional, some busses have bus specific callbacks, hence we may want
> a bus specific context at some point.
Then it's even better we went with the generics vs using mutable
references :)
> However, we can always change visibility as needed, so I'm fine making it sealed
> for now.
Couldn't you just add them here? Then sealing wouldn't be a problem.
---
Cheers,
Benno
Powered by blists - more mailing lists