[PATCH v2 3/3] rust: io: register: use path fragment for alias destination
Alexandre Courbot <[email protected]> Fri, 24 Jul 2026 20:37:06 +0900
| Newsgroups | dev.linux.lists.nova-gpu,dev.linux.lists.driver-core,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
The destination of an alias is always another register, i.e. a `struct` type. Replace the `ident` fragment with a `path` one in the internal rules: `path` is more accurate, and allows referencing registers using a qualified path instead of only identifiers visible from the current module. This covers all aliases, except the relative register ones which are to be removed soon. The public rule cannot be updated yet because a `+` can still be matched after the alias; add a TODO item to update it after relative registers are removed. Signed-off-by: Alexandre Courbot <[email protected]> --- rust/kernel/io/register.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rust/kernel/io/register.rs b/rust/kernel/io/register.rs index 32cab54aafff..c945eb149cd7 100644 --- a/rust/kernel/io/register.rs +++ b/rust/kernel/io/register.rs @@ -804,6 +804,9 @@ macro_rules! register { // Entry point for the macro, allowing multiple registers to be defined in one call. // It matches all possible register declaration patterns to dispatch them to corresponding // `@reg` rule that defines a single register. + // + // TODO: change `alias:ident` to `alias:path` once relative registers are replaced by I/O + // projections. ( $( $(#[$attr:meta])* $vis:vis $name:ident ($storage:ty) @@ -837,7 +840,7 @@ macro_rules! register { // Creates an alias register of fixed offset register `alias` with its own fields. ( - @reg $(#[$attr:meta])* $vis:vis $name:ident ($storage:ty) => $alias:ident + @reg $(#[$attr:meta])* $vis:vis $name:ident ($storage:ty) => $alias:path { $($fields:tt)* } ) => { $crate::register!(@bitfield $(#[$attr])* $vis struct $name($storage) { $($fields)* }); @@ -896,7 +899,7 @@ macro_rules! register { // Creates an alias of register `idx` of array of registers `alias` with its own fields. ( - @reg $(#[$attr:meta])* $vis:vis $name:ident ($storage:ty) => $alias:ident [ $idx:expr ] + @reg $(#[$attr:meta])* $vis:vis $name:ident ($storage:ty) => $alias:path [ $idx:expr ] { $($fields:tt)* } ) => { $crate::build_assert::static_assert!( -- 2.55.0