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