Re: [PATCH v11 4/4] rust: platform: allow ioremap of platform resources

From: Danilo Krummrich
Date: Wed Jul 02 2025 - 06:36:51 EST


On 7/1/25 4:34 PM, Daniel Almeida wrote:
+impl Device<device::Bound> {

<snip>

+ pub fn iomap_resource_sized<const SIZE: usize>(
+ &self,
+ resource: &Resource,
+ ) -> Result<impl PinInit<Devres<IoMem<SIZE>>, Error> + '_> {
+ IoMem::new(resource, self.as_ref())
+ }

Sorry that I did not catch this earlier, but what if I supply a Resource here
that has *not* been obtained by any of the platform::Device methods and from the
same platform::Device as you call this function for?

I think this also needs something similar to what we do in the IRQ abstraction,
e.g.:

/// # Invariants
///
/// `res` has been obtained from `dev`.
pub struct IoRequest<'a> {
dev: &'a Device<Bound>,
res: &'a Resource,
}

Such that IoMem::new() can take an IoRequest instance instead.