public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Maurice Hieronymus <mhi@mailbox.org>
To: dakr@kernel.org
Cc: aliceryhl@google.com, acourbot@nvidia.com, airlied@gmail.com,
	simona@ffwll.ch, nouveau@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	ojeda@kernel.org, boqun.feng@gmail.com, gary@garyguo.net,
	bjorn3_gh@protonmail.com, lossin@kernel.org,
	a.hindborg@kernel.org, tmgross@umich.edu, mhi@mailbox.org,
	rust-for-linux@vger.kernel.org
Subject: [PATCH v2 2/2] gpu: nova-core: Use derive Display for Chipset enum
Date: Sun,  4 Jan 2026 21:07:32 +0100	[thread overview]
Message-ID: <20260104200733.190494-3-mhi@mailbox.org> (raw)
In-Reply-To: <20260104200733.190494-1-mhi@mailbox.org>

Use the derive macro for implementing fmt::Display on the Chipset enum
instead of relying on the compiler-generated Display output. This ensures
stable display strings that won't change unexpectedly.

Signed-off-by: Maurice Hieronymus <mhi@mailbox.org>
---
 drivers/gpu/nova-core/gpu.rs | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index 629c9d2dc994..db2e913f85bf 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -4,6 +4,7 @@
     device,
     devres::Devres,
     fmt,
+    macros,
     pci,
     prelude::*,
     sync::Arc, //
@@ -26,7 +27,7 @@ macro_rules! define_chipset {
     ({ $($variant:ident = $value:expr),* $(,)* }) =>
     {
         /// Enum representation of the GPU chipset.
-        #[derive(fmt::Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
+        #[derive(macros::Display, fmt::Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
         pub(crate) enum Chipset {
             $($variant = $value),*,
         }
@@ -107,20 +108,6 @@ pub(crate) fn arch(&self) -> Architecture {
     }
 }
 
-// TODO
-//
-// The resulting strings are used to generate firmware paths, hence the
-// generated strings have to be stable.
-//
-// Hence, replace with something like strum_macros derive(Display).
-//
-// For now, redirect to fmt::Debug for convenience.
-impl fmt::Display for Chipset {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "{self:?}")
-    }
-}
-
 /// Enum representation of the GPU generation.
 ///
 /// TODO: remove the `Default` trait implementation, and the `#[default]`
-- 
2.51.2


      parent reply	other threads:[~2026-01-04 20:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-04 20:07 [PATCH v2 0/2] rust: macros: Add derive Display for enums Maurice Hieronymus
2026-01-04 20:07 ` [PATCH v2 1/2] " Maurice Hieronymus
2026-01-05  9:02   ` Benno Lossin
2026-01-05 10:29     ` Danilo Krummrich
2026-01-05 14:42       ` Benno Lossin
2026-01-05 15:00         ` Danilo Krummrich
2026-01-05 15:23           ` Maurice Hieronymus
2026-01-05 16:11       ` Gary Guo
2026-01-05 21:11         ` Maurice Hieronymus
2026-01-05 22:03           ` Danilo Krummrich
2026-01-06  5:56             ` Maurice Hieronymus
2026-01-06 12:56               ` Benno Lossin
2026-01-04 20:07 ` Maurice Hieronymus [this message]

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=20260104200733.190494-3-mhi@mailbox.org \
    --to=mhi@mailbox.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@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 \
    /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