lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5fa42689-4f7b-4770-bc44-a4c17d9de79f@kernel.org>
Date: Fri, 29 Aug 2025 23:46:29 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: John Hubbard <jhubbard@...dia.com>
Cc: Alexandre Courbot <acourbot@...dia.com>,
 Joel Fernandes <joelagnelf@...dia.com>, Timur Tabi <ttabi@...dia.com>,
 Alistair Popple <apopple@...dia.com>, David Airlie <airlied@...il.com>,
 Simona Vetter <simona@...ll.ch>, Bjorn Helgaas <bhelgaas@...gle.com>,
 Krzysztof Wilczyński <kwilczynski@...nel.org>,
 Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
 Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>,
 Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
 Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
 nouveau@...ts.freedesktop.org, linux-pci@...r.kernel.org,
 rust-for-linux@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
 Elle Rhumsaa <elle@...thered-steel.dev>
Subject: Re: [PATCH v7 5/6] rust: pci: use pci::Vendor instead of
 bindings::PCI_VENDOR_ID_*

On 8/29/25 11:38 PM, John Hubbard wrote:
> On 8/28/25 6:59 AM, Danilo Krummrich wrote:
>> On 8/28/25 3:25 PM, Alexandre Courbot wrote:
>>> 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?
>>
>> I think that's because in v2 vendor_id() still returns the raw value. I think it
> 
> That is correct.
> 
>> makes a little more sense if this patch simply introduces the example as an
>> example for vendor_id() itself.
>>
>> I think struct Vendor does not necessarily need an example by itself.
> 
> I'm not quite sure if you are asking for a change to this patch? The
> example already exercises .vendor_id(), so...?

Yes, I think the example above should be on the vendor_id() method rather than
on the Vendor struct and should be introduced by this patch.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ