[PATCH v2 1/4] rust: io: Add big-endian read and write functions

Daniel Almeida daniel.almeida at collabora.com
Fri Feb 6 04:28:01 AEDT 2026



> On 5 Feb 2026, at 12:16, Gary Guo <gary at garyguo.net> wrote:
> 
> On Thu Feb 5, 2026 at 2:28 PM GMT, Daniel Almeida wrote:
>> 
>> 
>>> On 4 Feb 2026, at 12:18, Danilo Krummrich <dakr at kernel.org> wrote:
>>> 
>>> On Wed Feb 4, 2026 at 5:04 AM CET, Link Mauve wrote:
>>>> Another option would be to call u32::swap_bytes() on the data being
>>>> read/written, but these helpers make the Rust code as ergonomic as the C
>>>> code.
>>>> 
>>>> Signed-off-by: Link Mauve <linkmauve at linkmauve.fr>
>>> 
>>> The I/O stuff recently changed quite significantly, please have a look at the
>>> driver-core-next branch [1] in the driver-core tree.
>>> 
>>> Also, instead of providing additional *be() methods, we should just create a new
>>> type io::Endianness and use it to indicate the device endianness when requesting
>>> the I/O resource.
>>> 
>>> For instance, for your driver we could have
>>> 
>>> request.iomap_exclusive_sized::<8>(Endianness::Big)?
>> 
>> Can we please structure this in a way that LittleEndian is the default?
>> Perhaps using a const generic that is defaulted, or something along these lines.
> 
> I think we should have everything default to little endian, and have wrapper
> types that do big endian which require expicit construction, similar to
> RelaxedMmio in Alex's series.
> 
> Best,
> Gary
> 

Ah yes, the RelaxedMmio pattern is definitely a good one. I agree that we should head in this direction.

— Daniel



More information about the Linuxppc-dev mailing list