[PATCH v7 5/6] rust: pci: use pci::Vendor instead of bindings::PCI_VENDOR_ID_*

Alexandre Courbot acourbot at nvidia.com
Thu Aug 28 13:25:18 UTC 2025


On Wed Aug 27, 2025 at 8:12 AM JST, John Hubbard wrote:
<snip>
> diff --git a/rust/kernel/pci/id.rs b/rust/kernel/pci/id.rs
> index 4b0ad8d4edc6..fd7a789e3015 100644
> --- a/rust/kernel/pci/id.rs
> +++ b/rust/kernel/pci/id.rs
> @@ -118,15 +118,14 @@ fn try_from(value: u32) -> Result<Self, Self::Error> {
>  /// ```
>  /// # use kernel::{device::Core, pci::{self, Vendor}, prelude::*};
>  /// fn log_device_info(pdev: &pci::Device<Core>) -> Result<()> {
> -///     // Compare raw vendor ID with known vendor constant
> -///     let vendor_id = pdev.vendor_id();
> -///     if vendor_id == Vendor::NVIDIA.as_raw() {
> -///         dev_info!(
> -///             pdev.as_ref(),
> -///             "Found NVIDIA device: 0x{:x}\n",
> -///             pdev.device_id()
> -///         );
> -///     }
> +///     // Get the validated PCI vendor ID
> +///     let vendor = pdev.vendor_id();
> +///     dev_info!(
> +///         pdev.as_ref(),
> +///         "Device: Vendor={}, Device=0x{:x}\n",
> +///         vendor,
> +///         pdev.device_id()
> +///     );

Why not use this new example starting from patch 2, which introduced the
previous code that this patch removes?



More information about the Nouveau mailing list