mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Almeida <daniel.almeida@collabora.com>
To: Daniel Almeida <daniel.almeida@collabora.com>,
	 Alice Ryhl <aliceryhl@google.com>,
	Danilo Krummrich <dakr@kernel.org>,
	 David Airlie <airlied@gmail.com>,
	Simona Vetter <simona@ffwll.ch>
Cc: Kaiqi Guo <chaoji_xinren@163.com>,
	 Alexandre Courbot <acourbot@nvidia.com>,
	dri-devel@lists.freedesktop.org,  rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] drm/tyr: use the `TryFrom` derive for `EntryType`
Date: Thu, 26 Nov 2026 17:10:46 -0300	[thread overview]
Message-ID: <20261126-tyr-enum-derives-v1-4-a487b0e1bee3@collabora.com> (raw)
In-Reply-To: <20261126-tyr-enum-derives-v1-0-a487b0e1bee3@collabora.com>

`EntryType` is the last enum in Tyr whose conversion from `Bounded` is
written by hand. Derive it as well, so that all of them use the
conversion derives.

No functional change intended.

Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
---
 drivers/gpu/drm/tyr/fw/parser.rs | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/tyr/fw/parser.rs b/drivers/gpu/drm/tyr/fw/parser.rs
index 6576bc870982..cf8a815e8ab8 100644
--- a/drivers/gpu/drm/tyr/fw/parser.rs
+++ b/drivers/gpu/drm/tyr/fw/parser.rs
@@ -18,10 +18,8 @@
 use kernel::{
     bitfield,
     device::Device,
-    num::{
-        casts::FromSafeCast,
-        Bounded, //
-    },
+    macros::TryFrom,
+    num::casts::FromSafeCast,
     prelude::*,
     sizes::SizeConstants, //
 };
@@ -548,7 +546,8 @@ fn entry_type(&self) -> Result<EntryType> {
     }
 }
 
-#[derive(Clone, Copy, Debug)]
+#[derive(Clone, Copy, Debug, TryFrom)]
+#[try_from(Bounded<u32, 8>)]
 #[repr(u8)]
 enum EntryType {
     /// Host <-> FW interface.
@@ -564,19 +563,3 @@ enum EntryType {
     /// Metadata about how the FW binary was built.
     BuildInfoMetadata = 6,
 }
-
-impl TryFrom<Bounded<u32, 8>> for EntryType {
-    type Error = Error;
-
-    fn try_from(value: Bounded<u32, 8>) -> Result<Self, Self::Error> {
-        match value.get() {
-            0 => Ok(EntryType::Iface),
-            1 => Ok(EntryType::Config),
-            2 => Ok(EntryType::FutfTest),
-            3 => Ok(EntryType::TraceBuffer),
-            4 => Ok(EntryType::TimelineMetadata),
-            6 => Ok(EntryType::BuildInfoMetadata),
-            _ => Err(EINVAL),
-        }
-    }
-}

-- 
2.56.0


      parent reply	other threads:[~2026-11-26 20:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 20:10 [PATCH 0/4] drm/tyr: use the conversion derives for the enums Daniel Almeida
2026-11-26 20:10 ` [PATCH 1/4] drm/tyr: use the conversion derives for the GPU_CONTROL enums Daniel Almeida
2026-11-26 20:10 ` [PATCH 2/4] drm/tyr: use the conversion derives for the MMU_AS_CONTROL enums Daniel Almeida
2026-11-26 20:10 ` [PATCH 3/4] drm/tyr: use the conversion derives for `CacheMode` Daniel Almeida
2026-11-26 20:10 ` Daniel Almeida [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=20261126-tyr-enum-derives-v1-4-a487b0e1bee3@collabora.com \
    --to=daniel.almeida@collabora.com \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=chaoji_xinren@163.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    /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

all inboxes | Powered by JetHome®