On 9/1/25 7:58 AM, Danilo Krummrich wrote:
On Sat Aug 30, 2025 at 12:36 AM CEST, John Hubbard wrote:
Changes since v7:
* Applied changes from Danilo's and Alex's and reviews (thanks!):
* Removed a blank line, one each, from the Class and Vendor macros.
* Moved example code location from struct Vendor, to vendor_id(),
and introduced it in a later commit, in its final form.
* Applied Alex's Reviewed-by tag to the series.
I think you forgot to align Debug and Display, i.e. Debug still prints decimal
values.
Is this intentional? If not, no worries, I can fix it up on apply (which a few
minor doc-comment nits):
Yes, I missed that one. Fixup on apply would be great, yes.
thanks,
John Hubbard
diff --git a/rust/kernel/pci/id.rs b/rust/kernel/pci/id.rs
index f6ce8f8a2a4d..f534133aed3d 100644
--- a/rust/kernel/pci/id.rs
+++ b/rust/kernel/pci/id.rs
@@ -26,7 +26,7 @@
/// Ok(())
/// }
/// ```
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(transparent)]
pub struct Class(u32);
@@ -81,12 +81,18 @@ const fn to_24bit_class(val: u32) -> u32 {
}
}
-impl fmt::Display for Class {
+impl fmt::Debug for Class {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "0x{:06x}", self.0)
}
}
+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]