Re: [PATCH v2 06/16] rust: io: register: allow explicit base type specification

"Alexandre Courbot" <[email protected]>
Newsgroups dev.linux.lists.nova-gpu,dev.linux.lists.driver-core,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:
> Currently registers work for all untyped I/O regions, which is not ideal.
> It allows registers defined for device A to work for another device B and
> there is no safeguarding at all.
>
> All users of the `register!` macro know what type it will be operating on,
> and that type is consistent across the driver. Therefore, add a `base`
> parameter to `register!`.
>
> Currently this parameter is unused in the generated code; it will be used
> when all users of `register!` is converted to gain the parameter.
>
> Signed-off-by: Gary Guo <[email protected]>

I did push back a bit on v1 about making this mandatory, but this makes
a lot more sense once you consider that by the end of this series, the
`register!` macro does not really define registers anymore: it defines
the layout of an address space - that you can define register types with
it is just a convenience shortcut.

With that framing, it is much more defensible to have to specify the
type (or at least the size) of the address space itself. I guess we
ought to rename `register!` at some point in the near future (not
necessarily with this series).
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.