[PATCH v2 2/2] gpu: nova-core: gsp: use () as message type for GspInitDone message

Alexandre Courbot posted 2 patches 1 week, 4 days ago
[PATCH v2 2/2] gpu: nova-core: gsp: use () as message type for GspInitDone message
Posted by Alexandre Courbot 1 week, 4 days ago
`GspInitDone` has no payload whatsoever, so the unit type `()` is the
correct way to represent its message content. We can use it now that
`()` implements `FromBytes`.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/nova-core/gsp/commands.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
index 0425c65b5d6f..2050771f9b53 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -142,7 +142,7 @@ fn init_variable_payload(
 }
 
 /// Message type for GSP initialization done notification.
-struct GspInitDone {}
+struct GspInitDone;
 
 // SAFETY: `GspInitDone` is a zero-sized type with no bytes, therefore it
 // trivially has no uninitialized bytes.
@@ -151,13 +151,13 @@ unsafe impl FromBytes for GspInitDone {}
 impl MessageFromGsp for GspInitDone {
     const FUNCTION: MsgFunction = MsgFunction::GspInitDone;
     type InitError = Infallible;
-    type Message = GspInitDone;
+    type Message = ();
 
     fn read(
         _msg: &Self::Message,
         _sbuffer: &mut SBufferIter<array::IntoIter<&[u8], 2>>,
     ) -> Result<Self, Self::InitError> {
-        Ok(GspInitDone {})
+        Ok(GspInitDone)
     }
 }
 

-- 
2.52.0
Re: [PATCH v2 2/2] gpu: nova-core: gsp: use () as message type for GspInitDone message
Posted by Alistair Popple 1 week, 4 days ago
On 2025-12-08 at 20:54 +1100, Alexandre Courbot <acourbot@nvidia.com> wrote...
> `GspInitDone` has no payload whatsoever, so the unit type `()` is the
> correct way to represent its message content. We can use it now that
> `()` implements `FromBytes`.

Much nicer, thanks.

Reviewed-by: Alistair Popple <apopple@nvidia.com>

> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
>  drivers/gpu/nova-core/gsp/commands.rs | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
> index 0425c65b5d6f..2050771f9b53 100644
> --- a/drivers/gpu/nova-core/gsp/commands.rs
> +++ b/drivers/gpu/nova-core/gsp/commands.rs
> @@ -142,7 +142,7 @@ fn init_variable_payload(
>  }
>  
>  /// Message type for GSP initialization done notification.
> -struct GspInitDone {}
> +struct GspInitDone;
>  
>  // SAFETY: `GspInitDone` is a zero-sized type with no bytes, therefore it
>  // trivially has no uninitialized bytes.
> @@ -151,13 +151,13 @@ unsafe impl FromBytes for GspInitDone {}
>  impl MessageFromGsp for GspInitDone {
>      const FUNCTION: MsgFunction = MsgFunction::GspInitDone;
>      type InitError = Infallible;
> -    type Message = GspInitDone;
> +    type Message = ();
>  
>      fn read(
>          _msg: &Self::Message,
>          _sbuffer: &mut SBufferIter<array::IntoIter<&[u8], 2>>,
>      ) -> Result<Self, Self::InitError> {
> -        Ok(GspInitDone {})
> +        Ok(GspInitDone)
>      }
>  }
>  
> 
> -- 
> 2.52.0
>