From: John Hubbard <jhubbard@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>
Cc: "Alexandre Courbot" <acourbot@nvidia.com>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
"Timur Tabi" <ttabi@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
nouveau@lists.freedesktop.org, linux-pci@vger.kernel.org,
rust-for-linux@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] rust: pci: display symbolic PCI vendor names
Date: Wed, 24 Sep 2025 18:38:35 -0700 [thread overview]
Message-ID: <02809090-539e-433f-a13b-14bd17bafe54@nvidia.com> (raw)
In-Reply-To: <20250925013359.414526-3-jhubbard@nvidia.com>
On 9/24/25 6:33 PM, John Hubbard wrote:
> The Display implementation for Vendor was forwarding directly to Debug
> printing, resulting in raw hex values instead of PCI Vendor strings.
>
> Improve things by doing a stringify!() call for each PCI Vendor item.
> This now prints symbolic names such as "NVIDIA", instead of
> "Vendor(0x10de)". It still falls back to Debug formatting for unknown
> class values.
>
> Suggested-by: Danilo Krummrich <dakr@kernel.org>
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> ---
> rust/kernel/pci/id.rs | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/rust/kernel/pci/id.rs b/rust/kernel/pci/id.rs
> index 6e081de30faf..63db4d5f5617 100644
> --- a/rust/kernel/pci/id.rs
> +++ b/rust/kernel/pci/id.rs
> @@ -135,6 +135,18 @@ impl Vendor {
> pub const $variant: Self = Self($binding as u16);
> )+
> }
> +
> + impl fmt::Display for Vendor {
> + #[inline]
That #[inline] snuck in somehow (it's not in Class), but it should
not be there, because this expands to many lines of implementation.
If there is a v2 I'll remove it, otherwise maybe we can just ask
the maintainer to snip out that line.
thanks,
John Hubbard
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + match self {
> + $(
> + &Self::$variant => write!(f, stringify!($variant)),
> + )+
> + _ => <Self as fmt::Debug>::fmt(self, f),
> + }
> + }
> + }
> };
> }
>
> @@ -160,13 +172,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> }
> }
>
> -impl fmt::Display for Vendor {
> - #[inline]
> - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> - <Self as fmt::Debug>::fmt(self, f)
> - }
> -}
> -
> define_all_pci_classes! {
> NOT_DEFINED = bindings::PCI_CLASS_NOT_DEFINED, // 0x000000
> NOT_DEFINED_VGA = bindings::PCI_CLASS_NOT_DEFINED_VGA, // 0x000100
next prev parent reply other threads:[~2025-09-25 1:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-25 1:33 [PATCH 0/2] rust: pci: display symbolic PCI vendor and class names John Hubbard
2025-09-25 1:33 ` [PATCH 1/2] rust: pci: display symbolic PCI " John Hubbard
2025-09-25 1:33 ` [PATCH 2/2] rust: pci: display symbolic PCI vendor names John Hubbard
2025-09-25 1:38 ` John Hubbard [this message]
2025-09-25 3:01 ` [PATCH 0/2] rust: pci: display symbolic PCI vendor and class names Alexandre Courbot
2025-09-25 23:27 ` John Hubbard
2025-09-25 16:04 ` Danilo Krummrich
2025-09-25 23:28 ` John Hubbard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=02809090-539e-433f-a13b-14bd17bafe54@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=joelagnelf@nvidia.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=ttabi@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).