[PATCH v3 2/6] gpu: nova-core: vbios: do not use `as` when comparing BiosImageType

Alexandre Courbot posted 6 patches 3 months, 1 week ago
[PATCH v3 2/6] gpu: nova-core: vbios: do not use `as` when comparing BiosImageType
Posted by Alexandre Courbot 3 months, 1 week ago
Use the `image_type` method and compare its result to avoid using `as`.

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

diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
index 74ed6d61e6cc..7c1bf10b2eac 100644
--- a/drivers/gpu/nova-core/vbios.rs
+++ b/drivers/gpu/nova-core/vbios.rs
@@ -709,9 +709,8 @@ fn image_type(&self) -> Result<BiosImageType> {
 
     /// Check if this is the last image.
     fn is_last(&self) -> bool {
-        // For NBSI images (type == 0x70), return true as they're
-        // considered the last image
-        if self.pcir.code_type == BiosImageType::Nbsi as u8 {
+        // For NBSI images, return true as they're considered the last image
+        if self.image_type() == Ok(BiosImageType::Nbsi) {
             return true;
         }
 

-- 
2.51.0
Re: [PATCH v3 2/6] gpu: nova-core: vbios: do not use `as` when comparing BiosImageType
Posted by Joel Fernandes 3 months, 1 week ago
On Wed, Oct 29, 2025 at 08:12:10AM +0900, Alexandre Courbot wrote:
> Use the `image_type` method and compare its result to avoid using `as`.
> 
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
>  drivers/gpu/nova-core/vbios.rs | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
> index 74ed6d61e6cc..7c1bf10b2eac 100644
> --- a/drivers/gpu/nova-core/vbios.rs
> +++ b/drivers/gpu/nova-core/vbios.rs
> @@ -709,9 +709,8 @@ fn image_type(&self) -> Result<BiosImageType> {
>  
>      /// Check if this is the last image.
>      fn is_last(&self) -> bool {
> -        // For NBSI images (type == 0x70), return true as they're
> -        // considered the last image
> -        if self.pcir.code_type == BiosImageType::Nbsi as u8 {
> +        // For NBSI images, return true as they're considered the last image
> +        if self.image_type() == Ok(BiosImageType::Nbsi) {

nit: Could you add period at the end of the comment sentence as Miguel
suggested in the other thread (which I admit the initial code also didn't
have)?

With that change,

Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>

thanks,

 - Joel


>              return true;
>          }
>  
> 
> -- 
> 2.51.0
>
Re: [PATCH v3 2/6] gpu: nova-core: vbios: do not use `as` when comparing BiosImageType
Posted by Alexandre Courbot 3 months ago
On Tue Nov 4, 2025 at 5:31 AM JST, Joel Fernandes wrote:
> On Wed, Oct 29, 2025 at 08:12:10AM +0900, Alexandre Courbot wrote:
>> Use the `image_type` method and compare its result to avoid using `as`.
>> 
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>> ---
>>  drivers/gpu/nova-core/vbios.rs | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
>> index 74ed6d61e6cc..7c1bf10b2eac 100644
>> --- a/drivers/gpu/nova-core/vbios.rs
>> +++ b/drivers/gpu/nova-core/vbios.rs
>> @@ -709,9 +709,8 @@ fn image_type(&self) -> Result<BiosImageType> {
>>  
>>      /// Check if this is the last image.
>>      fn is_last(&self) -> bool {
>> -        // For NBSI images (type == 0x70), return true as they're
>> -        // considered the last image
>> -        if self.pcir.code_type == BiosImageType::Nbsi as u8 {
>> +        // For NBSI images, return true as they're considered the last image
>> +        if self.image_type() == Ok(BiosImageType::Nbsi) {
>
> nit: Could you add period at the end of the comment sentence as Miguel
> suggested in the other thread (which I admit the initial code also didn't
> have)?
>
> With that change,
>
> Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>

Done and merged this patch and patch 3/6, thanks! I will follow with the
rest this week unless someone screams at the kernel-wide RFC I send for
patch 4/6 [1].

[1] https://lore.kernel.org/rust-for-linux/20251104-as_casts-v1-1-0a0e95bd2a9f@nvidia.com/T/#u