Re: [PATCH v2 15/16] rust: io: register: remove `Register` trait and cleanup macro
"Alexandre Courbot" <[email protected]>
| Newsgroups | dev.linux.lists.driver-core,dev.linux.lists.nova-gpu,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
On Thu Aug 6, 2026 at 1:35 AM JST, Gary Guo wrote:
<...>
> @@ -601,11 +605,22 @@ macro_rules! register {
> { $($fields:tt)* }
> $($rest:tt)*
> ) => {
> - $crate::register!(@bitfield $(#[$attr])* $vis struct $name($storage) { $($fields)* });
> - $crate::register!(@io_base $reg_base; $name
> - @ $crate::register!(@offset $(@ $offset)? $(=> $alias $([$alias_idx])?)?)
> + $crate::bitfield!(
> + #[allow(non_camel_case_types)]
> + $(#[$attr])* $vis struct $name($storage) { $($fields)* }
> );
> - $crate::register!(@io_fixed $(#[$attr])* $vis $name);
> +
> + impl $crate::io::register::FixedRegister for $name {
> + type Base = $reg_base;
> +
> + const OFFSET: usize =
> + $crate::register!(@offset $(@ $offset)? $(=> $alias $([$alias_idx])?)?);
Btw, are the bases properly checked when using aliases? It looks like we
are expecting the base type of the *current* register block instead of
the one of the alias, which if true could lead to inconsistencies.