Re: [PATCH v15 2/3] rust: io: mem: add a generic iomem abstraction

From: Daniel Almeida
Date: Fri Jul 18 2025 - 08:24:43 EST


Hi Danilo,

> On 17 Jul 2025, at 16:45, Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> On Thu Jul 17, 2025 at 5:55 PM CEST, Daniel Almeida wrote:
>> +impl<const SIZE: usize> IoMem<SIZE> {
>> + fn ioremap(resource: &Resource) -> Result<Self> {
>> + // Note: It looks like there aren't any 32-bit architectures that define
>> + // ioremap_np. This means that sometimes this conversion will fail. If
>> + // we performed a lossy cast, i.e., using `as`, then `bindings::ioremap`
>> + // would return NULL anyway.
>
> Why would ioremap() return NULL if you perform a lossy cast?
>
> Anyways, I find it a bit difficult to decode the actual problem from the above
> description.
>
> I feel it would be better to just explain that some ioremap() implementations
> use types that depend on the CPU word width rather than the bus address width.
>
> If you agree, no need to resend though, we can change it when applying the
> series.
>
>> + // TODO: Properly address this in the C code to avoid this `try_into`.
>> + let size = resource.size().try_into()?;
>> + if size == 0 {
>> + return Err(EINVAL);
>> + }
>

Ok, I do agree that what you said is better. Feel free to use it then.

— Daniel