Re: [PATCH v2 16/16] rust: io: register: unify handling of register with/without bitfields

"Gary Guo" <[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 Fri Aug 14, 2026 at 2:56 PM BST, Alexandre Courbot wrote:
> On Thu Aug 6, 2026 at 1:35 AM JST, Gary Guo wrote:
> <...>
>> @@ -577,6 +547,9 @@ macro_rules! register {
>>      (base: $reg_base:ty;) => {};
>>  
>>      // Creates a register at a fixed offset of the MMIO space with provided type.
>> +    //
>> +    // This handles all of the fixed offset `@ offset`, alias of register `=> alias` and alias of
>> +    // register array element `=> alias[idx]` cases.
>>      (
>>          base: $reg_base:ty;
>>          // `$ty` cannot be `:ty` due to follow-set restrictions.
>> @@ -593,10 +566,29 @@ macro_rules! register {
>>          $crate::register!(base: $reg_base; $($rest)*);
>>      };
>>  
>> +    // `#[unique]` indicates that this is the only register of this type in this given register.
>
> Sentence doesn't parse (in this given register?).

Oops, I meant "in the given region" (i.e. base type).

>
>> +    // Thus generate a `FixedIoLoc` impl for it as well.
>> +    (
>> +        base: $reg_base:ty;
>> +        $(#[$attr:meta])* $vis:vis $name:ident: #[unique] $ty: ident $(:: $path_frag:ident)*
>> +            $(@ $offset:literal)?
>> +            $(=> $alias:path $([$alias_idx:expr])? )?;
>> +        $($rest:tt)*
>
> This rule looks like it should be private, or am I mistaken?

The idea is that if you create bitfield yourself you can still use `#[unique]`
to bring back the `FixedIoLoc` impl so you're not losing any expressiveness
compared to let `register!()` macro generating it.

Best,
Gary
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.