Re: [PATCH v11 4/5] rust: pci: add config space read/write support

From: Gary Guo

Date: Wed Jan 21 2026 - 12:40:55 EST


On Wed Jan 21, 2026 at 5:12 PM GMT, Danilo Krummrich wrote:
> On Wed Jan 21, 2026 at 4:36 PM CET, Gary Guo wrote:
>>> +/// The PCI configuration space of a device.
>>> +///
>>> +/// Provides typed read and write accessors for configuration registers
>>> +/// using the standard `pci_read_config_*` and `pci_write_config_*` helpers.
>>> +///
>>> +/// The generic const parameter `SIZE` can be used to indicate the
>>> +/// maximum size of the configuration space (e.g. `ConfigSpaceSize::Normal`
>>> +/// or `ConfigSpaceSize::Extended`).
>>> +pub struct ConfigSpace<'a, const SIZE: usize = { ConfigSpaceSize::Extended as usize }> {
>>
>> This is quite long to write. Given that it'll either be normal or extended, can
>> we just have two marker types instead? So you have
>>
>> ConfigSpace<Normal> and ConfigSpace<Extended>
>
> I think in practice users don't have the need to write it anyways. You'd access
> the config space with either
>
> let config = pdev.config_space()?;
>
> or
>
> let config = pdev.config_space_extended()?;
>

I suspect when they need to write it, they'll just write `ConfigSpace<256>`
which'll be accepted by the compiler.

Also I don't see why we wouldn't want this to use types to begin with, even if
in practice users don't need to write out the type names.

Best,
Gary

> i.e. there is no need to store an instance of the struct anywhere.
>
> Should it turn out that we do need it for some reason in the future we can do
> this as follow-up, I think.