]> Gentwo Git Trees - linux/.git/commitdiff
gpu: nova-core: bitfield: simplify expression
authorAlexandre Courbot <acourbot@nvidia.com>
Wed, 22 Oct 2025 10:50:57 +0000 (19:50 +0900)
committerAlexandre Courbot <acourbot@nvidia.com>
Sat, 25 Oct 2025 04:16:31 +0000 (13:16 +0900)
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/
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Message-ID: <20251022-nova-bitfield-v1-2-73bc0988667b@nvidia.com>

drivers/gpu/nova-core/bitfield.rs

index 136de7289162900d71da565110e6ac068257c063..f113439c6501ab4370dae61b5d676b8005e221c8 100644 (file)
@@ -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;
         );
 
         $(