[PATCH 2/3] gpu: nova-core: bitfield: simplify expression

Alexandre Courbot posted 3 patches 3 months, 2 weeks ago
[PATCH 2/3] gpu: nova-core: bitfield: simplify expression
Posted by Alexandre Courbot 3 months, 2 weeks ago
The shift is more easily expressed by the index of the lowest bit of the
field.

Reported-by: Edwin Peer <epeer@nvidia.com>
Link: https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/nova-core/bitfield.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/nova-core/bitfield.rs b/drivers/gpu/nova-core/bitfield.rs
index 136de7289162..f113439c6501 100644
--- a/drivers/gpu/nova-core/bitfield.rs
+++ b/drivers/gpu/nova-core/bitfield.rs
@@ -268,7 +268,7 @@ impl $name {
                 _ => ::kernel::build_error!("Unsupported storage type size")
             }
         };
-        const [<$field:upper _SHIFT>]: u32 = Self::[<$field:upper _MASK>].trailing_zeros();
+        const [<$field:upper _SHIFT>]: u32 = $lo;
         );
 
         $(

-- 
2.51.0
Re: [PATCH 2/3] gpu: nova-core: bitfield: simplify expression
Posted by Joel Fernandes 3 months, 2 weeks ago

On 10/22/2025 6:50 AM, Alexandre Courbot wrote:
> The shift is more easily expressed by the index of the lowest bit of the
> field.
> 
> Reported-by: Edwin Peer <epeer@nvidia.com>
> Link: https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>

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

Thanks.