diff options
| author | Alexandre Courbot <acourbot@nvidia.com> | 2025-06-19 22:23:52 +0900 |
|---|---|---|
| committer | Danilo Krummrich <dakr@kernel.org> | 2025-06-23 18:12:30 +0200 |
| commit | cdfe233ee6cde6b82f0527fe7e0e599d4118b336 (patch) | |
| tree | b2f84a2ab09b272f145bdfa286106d6155981df3 | |
| parent | 8dd1433d905051f2d2e5ad8864da2de915a2f11f (diff) | |
gpu: nova-core: expose the offset of each register as a type constant
Although we want to access registers using the provided methods, it is
sometimes needed to use their raw offset, for instance when working with
a register array.
Expose the offset of each register using a type constant to avoid
resorting to hardcoded values.
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://lore.kernel.org/r/20250619-nova-frts-v6-8-ecf41ef99252@nvidia.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
| -rw-r--r-- | drivers/gpu/nova-core/regs/macros.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/gpu/nova-core/regs/macros.rs b/drivers/gpu/nova-core/regs/macros.rs index d7f09026390b..7cd013f3c90b 100644 --- a/drivers/gpu/nova-core/regs/macros.rs +++ b/drivers/gpu/nova-core/regs/macros.rs @@ -78,7 +78,7 @@ macro_rules! register { $($fields:tt)* } ) => { - register!(@common $name $(, $comment)?); + register!(@common $name @ $offset $(, $comment)?); register!(@field_accessors $name { $($fields)* }); register!(@io $name @ $offset); }; @@ -89,7 +89,7 @@ macro_rules! register { $($fields:tt)* } ) => { - register!(@common $name $(, $comment)?); + register!(@common $name @ $offset $(, $comment)?); register!(@field_accessors $name { $($fields)* }); register!(@io$name @ + $offset); }; @@ -98,7 +98,7 @@ macro_rules! register { // Defines the wrapper `$name` type, as well as its relevant implementations (`Debug`, `BitOr`, // and conversion to regular `u32`). - (@common $name:ident $(, $comment:literal)?) => { + (@common $name:ident @ $offset:literal $(, $comment:literal)?) => { $( #[doc=$comment] )? @@ -106,6 +106,11 @@ macro_rules! register { #[derive(Clone, Copy, Default)] pub(crate) struct $name(u32); + #[allow(dead_code)] + impl $name { + pub(crate) const OFFSET: usize = $offset; + } + // TODO: display the raw hex value, then the value of all the fields. This requires // matching the fields, which will complexify the syntax considerably... impl ::core::fmt::Debug for $name { |
