Re: [PATCH v7 3/3] rust: platform: allow ioremap of platform resources

From: Benno Lossin
Date: Tue Mar 18 2025 - 20:48:17 EST


On Tue Mar 18, 2025 at 7:22 PM CET, Daniel Almeida wrote:
> On 18 Mar 2025, at 14:43, Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>> On Tue, Mar 18, 2025 at 02:20:43PM -0300, Daniel Almeida wrote:
>>> + /// // Read and write a 32-bit value at `offset`. Calling `try_access()` on
>>> + /// // the `Devres` makes sure that the resource is still valid.
>>> + /// let data = iomem.try_access().ok_or(ENODEV)?.readl(offset);
>>> + ///
>>> + /// iomem.try_access().ok_or(ENODEV)?.writel(data, offset);
>>
>> I'd probably write this as
>>
>> || -> Result {
>> let iomem = iomem.try_access().ok_or(ENODEV)?;
>>
>> iomem.read32(offset);
>> iomem.write32(data, offset);
>>
>> Ok(())
>> }()?;

Why use a closure here?

---
Cheers,
Benno