Re: [PATCH 1/3] rust: uaccess: generalize write_dma() to accept any Coherent<T>
From: Danilo Krummrich
Date: Wed Mar 25 2026 - 09:55:22 EST
On Wed Mar 25, 2026 at 2:01 PM CET, Gary Guo wrote:
> I think there is a reason, which is that it weakens the strong typing that we
> have. I think it'll be better to have this be
>
> fn write_dma<T>(&mut self, view: View<'_, Coherent<T>, [u8]>, offset: usize) -> Result
>
> once we have I/O view and expect people to create cast views into bytes
> explicitly.
>
There is technically no difference between the above and the below, except that
for the above the user has to create the View first, i.e. it needs additional
code. What's the advantage?
>> + pub fn write_dma<T: KnownSize + AsBytes + ?Sized>(
>> + &mut self,
>> + alloc: &Coherent<T>,
>> + offset: usize,
>> + count: usize,
>> + ) -> Result {
<snip>
> Although, given that we already have APIs like
>
> fn write<T: AsBytes>(&mut self, value: &T)
>
> I'm okay with putting this in until we have a replacement solution.
Sounds good.