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

From: Miguel Ojeda
Date: Thu Feb 06 2025 - 11:12:12 EST


On Thu, Feb 6, 2025 at 4:59 PM Guangbo Cui <2407018371@xxxxxx> wrote:
>
> With CONFIG_RUST_BUILD_ASSERT_ALLOW=y enabled, this compilation succeeds.

Yes, that is expected too (but note that the config option is there
just in case -- it should not happen that it is needed in normal
builds).

> Even if the size is determined at compile time, the compilation will still fail
> if CONFIG_RUST_BUILD_ASSERT_ALLOW is not enabled.

Yes, that is expected -- the idea is that you cannot make the mistake
of calling those.

I think you are suggesting only exposing the methods in the case where
calling them would work? That would be great if a design allows for
it, of course.

By the way, Daniel, in patch 3/3 there is this comment:

+ /// // Unlike `ioremap_resource_sized`, here the size of the
memory region
+ /// // is not known at compile time, so only the `try_read*`
and `try_write*`
+ /// // family of functions are exposed, leading to runtime
checks on every
+ /// // access.

Is the "only ... are exposed" correct? i.e. are they exposed? / is
this potentially confusing?

Thanks!

Cheers,
Miguel