Re: [PATCH 2/8] rust: io: generalize `Mmio` to arbitrary type

From: Miguel Ojeda

Date: Sat Apr 04 2026 - 14:57:58 EST


On Mon, Mar 23, 2026 at 4:38 PM Gary Guo <gary@xxxxxxxxxx> wrote:
>
> From: Gary Guo <gary@xxxxxxxxxxx>
>
> Currently, `io::Mmio` always represent an untyped region of a compile-time
> known minimum size, which is roughly equivalent to `void __iomem*` (but
> with bound checks). However, it is useful to also be to represent I/O
> memory of a specific type, e.g. `u32 __iomem*` or `struct foo __iomem*`.
>
> Thus, make `Mmio` generic on arbitrary `T`, where `T` is a sized type, or a
> DST that implements `KnownSize`. Similar to the `MmioRaw` change, the
> existing behaviour is preserved in the form of `Mmio<Region<SIZE>>`. This
> change brings the MMIO closer to the DMA coherent allocation types that we
> have, which is already typed.
>
> To be able to implement `IoKnownSize`, add a `MIN_SIZE` constant to
> `KnownSize` trait to represent compile-time known minimum size of a
> specific type.
>
> Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>

Acked-by: Miguel Ojeda <ojeda@xxxxxxxxxx>

Cheers,
Miguel