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

Alexandre Courbot
2025-09-29T06:23:05Z

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/