On Fri, 2025-11-07 at 20:39 -0800, John Hubbard wrote:
> Implement Display for Spec. This simplifies the dev_info!() code for
> printing banners such as:
> 
>     NVIDIA (Chipset: GA104, Architecture: Ampere, Revision: a.1)
> 
> Cc: Alexandre Courbot <[email protected]>
> Cc: Danilo Krummrich <[email protected]>
> Cc: Timur Tabi <[email protected]>
> Signed-off-by: John Hubbard <[email protected]>

I'm okay with the entire patch set, but I do have a few questions.

> +impl fmt::Display for Spec {
> +    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> +        write!(
> +            f,
> +            "Chipset: {}, Architecture: {:?}, Revision: {}",
> +            self.chipset,
> +            self.chipset.arch(),
> +            self.revision
> +        )
> +    }
> +}
> +
>  /// Structure holding the resources required to operate the GPU.
>  #[pin_data]
>  pub(crate) struct Gpu {
> @@ -206,13 +218,7 @@ pub(crate) fn new<'a>(
>      ) -> impl PinInit<Self, Error> + 'a {
>          try_pin_init!(Self {
>              spec: Spec::new(bar).inspect(|spec| {
> -                dev_info!(
> -                    pdev.as_ref(),
> -                    "NVIDIA (Chipset: {}, Architecture: {:?}, Revision: 
> {})\n",
> -                    spec.chipset,
> -                    spec.chipset.arch(),
> -                    spec.revision
> -                );
> +                dev_info!(pdev.as_ref(),"NVIDIA ({})\n", spec);

I believe that this is the only place where a `Spec` is actually printed.  Does 
it really make
sense to implement Display for a single usage?  Do we generally want to 
implement Display for
new types?

Reply via email to