`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 <[email protected]> --- 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
