The Display implementation for Class was forwarding directly to Debug
printing, resulting in raw hex values instead of PCI Class strings.
Improve things by doing a stringify!() call for each PCI Class item.
This now prints symbolic names such as "DISPLAY_VGA", instead of
"Class(0x030000)". 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>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
pub const $variant: Self = Self(Self::to_24bit_class($binding));
)+
}
+
+ impl fmt::Display for Class {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ $(
+ &Self::$variant => write!(f, stringify!($variant)),
+ )+
+ _ => <Self as fmt::Debug>::fmt(self, f),
+ }
+ }
+ }
};
}
}
}
-impl fmt::Display for Class {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- <Self as fmt::Debug>::fmt(self, f)
- }
-}
-
impl ClassMask {
/// Get the raw mask value.
#[inline]