On Fri Nov 27, 2026 at 12:46 PM CET, Alexandre Courbot wrote:
> +bitfield! {
> +    /// Bus-Device-Function ID of a PCI device. Equivalent of C's 
> `PCI_DEVID`.

Please make the reference to the C API a separate line.

Additional nit, I'm not sure I'd use "equivalent" as Bdf is a type that can do a
few more things.

> +    pub struct Bdf(u16) {
> +        /// Bus number.
> +        15:8 bus;
> +        /// Device number.
> +        7:3 device;
> +        /// Function number.
> +        2:0 function;
> +        /// Aggregation of `device` and `function`, which are commonly used 
> together in code.
> +        7:0 devfn;
> +    }
> +}
> +
> +/// Formats the ID as `bus:device.function`, like the corresponding part of 
> C's `pci_name()`.
> +impl fmt::Display for Bdf {
> +    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> +        write!(
> +            f,
> +            "{:02x}:{:02x}.{}",
> +            self.bus(),
> +            self.device(),
> +            self.function()
> +        )
> +    }
> +}
> +
>  /// Abstraction for the PCI device ID structure ([`struct pci_device_id`]).
>  ///
>  /// [`struct pci_device_id`]: 
> https://docs.kernel.org/PCI/pci.html#c.pci_device_id
> @@ -700,10 +729,10 @@ pub fn revision_id(&self) -> u8 {
>  
>      /// Returns the PCI bus device/function.
>      #[inline]
> -    pub fn dev_id(&self) -> u16 {
> +    pub fn dev_id(&self) -> Bdf {

At a first glance I wasn't sure if the naming should align, i.e. whether Bdf
should be DevId instead, but I think this strikes a good balance: dev_id()
remains aligned with the C API and Bdf as a type is more on point than DevId.

With the above nit fixed,

Acked-by: Danilo Krummrich <[email protected]>

Reply via email to