[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <8A8152BD-A314-4A23-B104-AD802F7E2DB6@collabora.com>
Date: Wed, 16 Jul 2025 18:52:54 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>
Cc: linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v14 2/3] rust: io: mem: add a generic iomem abstraction
Hi,
[…]
> +
> +/// An exclusive memory-mapped IO region.
> +///
> +/// # Invariants
> +///
> +/// - [`ExclusiveIoMem`] has exclusive access to the underlying [`IoMem`].
> +pub struct ExclusiveIoMem<const SIZE: usize> {
> + /// The underlying `IoMem` instance.
> + iomem: IoMem<SIZE>,
> +
> + /// The region abstraction. This represents exclusive access to the
> + /// range represented by the underlying `iomem`.
> + ///
> + /// This field is needed for ownership of the region.
> + _region: Region,
> +}
> +
> +impl<const SIZE: usize> ExclusiveIoMem<SIZE> {
> + /// Creates a new `ExclusiveIoMem` instance.
> + fn ioremap(resource: &Resource) -> Result<Self> {
> + let start = resource.start();
> + let size = resource.size();
> + let name = resource.name().ok_or(EINVAL)?;
Note the change above. If there’s no name, we fail.
I just noticed that this may not be the right approach, but OTOH we should note that
“not having a name” is apparently considered a bug in the C code under some
circumstances:
struct resource *r = v, *p;
[…]
seq_printf(m, "%*s%0*llx-%0*llx : %s\n",
depth * 2, "",
width, start,
width, end,
r->name ? r->name : "<BAD>”); <—————
— Daniel
Powered by blists - more mailing lists