Re: [PATCH v3 1/1] rust: pci: add extended capability and SR-IOV support

From: Alexandre Courbot

Date: Sun Apr 26 2026 - 00:13:24 EST


On Mon Apr 20, 2026 at 7:13 PM JST, Zhi Wang wrote:
<snip>
>> > + return Err(EINVAL);
>> > + }
>> > + let low = crate::io_read!(self, .vf_bar[bar_index]?);
>> > + let high = crate::io_read!(self, .vf_bar[bar_index + 1]?);
>> >
>>
>> Don't we want to check whether the bar in question is actually a
>> 64-bit BAR?
>>
>> I wonder whether this also doesn't call for an iterator-based solution
>> returning an enum with the properly-sized BAR.
>
> Good point. I was assuming that the driver actually know its
> devcie support 64-bit bar or not. Do you prefer that we can have an
> iterator-based solution at this time? I think it makes the code looks
> nicer though. :)

It really depends on how this code is used. If we are going through the
list of BARs in client code, then yes, and iterator would be the
idiomatic solution.