Re: [PATCH v2 1/2] rust: introduce abstractions for fwctlg

Danilo Krummrich
2026-01-28T17:40:29Z

On Wed Jan 28, 2026 at 6:30 PM CET, Zhi Wang wrote:
> On Wed, 28 Jan 2026 17:35:04 +0100
> "Danilo Krummrich" <dakr@kernel.org> wrote:
>
>> On Wed Jan 28, 2026 at 4:56 PM CET, Jason Gunthorpe wrote:
>> > On Wed, Jan 28, 2026 at 04:49:07PM +0100, Danilo Krummrich wrote:
>
> snip
>
>> > Or is it needed to add the typestate?
>>
>> This is something we should consider when a fwctl::Device would have
>> different states it can be in, where calling certain methods of a
>> fwctl::Device is only valid for a certain state and would cause
>> undefined behavior if called from the wrong state.
>
> Are you saying we should define typestate like Device<Bound/Core> also for
> fwctl device? I haven't thought about this and some design consideration
> would be helpful, as the rust PCI subsystem has it, while some of other
> abstractions don't have it. I could start to picture about this if this
> is necessary.

No, I don't see a need for a type state for fwctl::Device.

The DeviceContext type states, such as Core, Bound, etc. are type states for bus
devices only. If you find other device structures that don't have this, then
those are not bus devices, but class devices (such as {pwm,drm,fwctl}::Device).