From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC0E830F7EA; Thu, 28 Aug 2025 13:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756389555; cv=none; b=IomWvVFFSFFNNgAeVtr1unIic16t1zQaV3bpQuTbT1WLchD7tilOWfa7B16iMVUGYj6WbplLJhg9pIC+BDtaYiGNdFv9uu+pKfNq3CsOY1PIP0YJRKnFJ9C1XEuVkhlKrCNmIgNSKfXu6xOT4rVmvyfgr+DrZspl4dOIzN4mE1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756389555; c=relaxed/simple; bh=WEtI0/FN3xpSJ6agHNJuplApkchRGtOGLb1rARd7JN4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=gFCnYbwmqjTvxpeYYAYTSUVC2QAVaTeBSAbvb182dmOkG3ZyPxgCANJ005c80CFNjUtxwyyrNOTr7tWUYnylYipQltckN8pXf/MiF5dRuo4OubBvZiSTVNCa6KYhOzwGXoEsb8Mh3aMGt2N1W8bZVfhWONvVPPBWJb1QDCDhmU8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hk71lSfC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Hk71lSfC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBDDFC4CEED; Thu, 28 Aug 2025 13:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756389555; bh=WEtI0/FN3xpSJ6agHNJuplApkchRGtOGLb1rARd7JN4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Hk71lSfCh0+8Gp8mDS+rJtbB16TzpROCk59jFIJkk8xGS3HPEjWs7IyU+hvCHsDyX 3WXeUuz+1EJlJfLab3Hoz3YfNT7H4smxqUWZEMhb4wkPS8aQlUhYLfVxbKLFQp7Nhw exXrt10hund93QkYlyiCZ6bEK++oMBaRJtZ392vGe7x9IpNoJlbYSH5GTsK4jQ5Owz 5GdfouP7S1kClIv/VeZv7H6WCLAa9eAudFg45QTbKm8TBPqUPZkhZpJ0waSFaxGOet RijKqRrBTkbT5vOT8Mp8SDuWvwhxEdPGvthIyALhqiG1yNbtaDZlYn94J8ioQ23jW7 jRzI8aXCNxLYg== Message-ID: <4b525afa-1031-4f99-a1ab-e89af77616eb@kernel.org> Date: Thu, 28 Aug 2025 15:59:09 +0200 Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 5/6] rust: pci: use pci::Vendor instead of bindings::PCI_VENDOR_ID_* To: Alexandre Courbot Cc: John Hubbard , Joel Fernandes , Timur Tabi , Alistair Popple , David Airlie , Simona Vetter , Bjorn Helgaas , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nouveau@lists.freedesktop.org, linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org, LKML , Elle Rhumsaa References: <20250826231224.1241349-1-jhubbard@nvidia.com> <20250826231224.1241349-6-jhubbard@nvidia.com> From: Danilo Krummrich Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/28/25 3:25 PM, Alexandre Courbot wrote: > On Wed Aug 27, 2025 at 8:12 AM JST, John Hubbard wrote: > >> 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 { >> /// ``` >> /// # use kernel::{device::Core, pci::{self, Vendor}, prelude::*}; >> /// fn log_device_info(pdev: &pci::Device) -> 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 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.