Re: [PATCH v4 2/6] nova-core: bitfield: Add support for different storage widths

Joel Fernandes
2025-09-29T19:47:42Z

On 9/29/2025 8:22 AM, Alexandre Courbot wrote:
> On Sun Sep 21, 2025 at 3:22 AM JST, Joel Fernandes wrote:
>> Previously, bitfields were hardcoded to use u32 as the underlying
>> storage type. Add support for different storage types (u8, u16, u32,
>> u64) to the bitfield macro.
>>
>> New syntax is: struct Name: <type ex., u32> { ... }
>>
>> Reviewed-by: Elle Rhumsaa <elle@weathered-steel.dev>
>> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
>> ---
>> drivers/gpu/nova-core/bitfield.rs | 71 +++++++++++++++++-----------
>> drivers/gpu/nova-core/regs/macros.rs | 16 +++----
>> 2 files changed, 52 insertions(+), 35 deletions(-)
>>
>> diff --git a/drivers/gpu/nova-core/bitfield.rs b/drivers/gpu/nova-core/bitfield.rs
>> index ba6b7caa05d9..687ef234be75 100644
>> --- a/drivers/gpu/nova-core/bitfield.rs
>> +++ b/drivers/gpu/nova-core/bitfield.rs
>> @@ -51,7 +51,7 @@
>> //! }
>> //!
>> //! bitfield! {
>> -//! struct ControlReg {
>> +//! struct ControlReg: u32 {
>
> Haven't we agreed in [1] to align the type definition syntax to that of
> an actual Rust struct? E.g. `struct ControlReg(u32)`?
>
> [1] https://lore.kernel.org/all/3814d6b7-7551-4e8c-b78a-4ac6236eb406@nvidia.com/

Sorry this slipped (conference travel and all :P). I will make the change this
time. Btw v5 also has other changes in addition to this, your review is much
appreciated :)

- Joel