From: Danilo Krummrich <dakr@kernel.org>
To: Daniel Almeida <daniel.almeida@collabora.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Mika Westerberg" <mika.westerberg@linux.intel.com>,
"Ying Huang" <huang.ying.caritas@gmail.com>,
"Benno Lossin" <lossin@kernel.org>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
"Fiona Behrens" <me@kloenk.dev>
Subject: Re: [PATCH v11 1/4] rust: io: add resource abstraction
Date: Wed, 2 Jul 2025 20:16:17 +0200 [thread overview]
Message-ID: <aGV3ce3ZJEOanSMJ@pollux> (raw)
In-Reply-To: <4DF66D6F-C89E-4472-AB76-B3EB1CB6F07C@collabora.com>
On Wed, Jul 02, 2025 at 03:11:04PM -0300, Daniel Almeida wrote:
> Hi Danilo
>
> > On 2 Jul 2025, at 07:21, Danilo Krummrich <dakr@kernel.org> wrote:
> >
> >> +#[cfg(CONFIG_HAS_IOPORT)]
> >> +/// Returns a reference to the global `ioport_resource` variable.
> >> +pub fn ioport_resource() -> &'static Resource {
> >> + // SAFETY: `bindings::ioport_resoure` has global lifetime and is of type Resource.
> >> + unsafe { Resource::as_ref(&raw mut bindings::ioport_resource) }
> >> +}
> >> +
> >> +#[cfg(CONFIG_HAS_IOMEM)]
> >> +/// Returns a reference to the global `iomem_resource` variable.
> >> +pub fn iomem_resource() -> &'static Resource {
> >> + // SAFETY: `bindings::iomem_resoure` has global lifetime and is of type Resource.
> >> + unsafe { Resource::as_ref(&raw mut bindings::iomem_resource) }
> >> +}
> >
> > This caught my attention, and I have a few questions:
> >
> > 1) What do you need them for? I don't see any methods that would usually
> > consume those.
> >
> > 2) Why are they behind CONFIG_HAS_IOPORT and CONFIG_HAS_IOMEM, even though the
> > C instances are not?
> >
> > 3) What happens if we pass them to IoMem::new()? Is this really safe, or do we
> > need them to be a special Resource type?
> >
>
> Good catch, actually.
>
> I worked on this patch with Fiona and IIRC, she needed access to these two for
> her LED abstractions. This patch has seen a few iterations already and this may
> or may not be obsolete by now. I must say I've never used these before so I
> don't really know how they work nor do I need this at all.
They serve as parent / root resource instances, e.g. if you want to create new
resource regions yourself.
> Fiona, do you still need these two accessors?
I'd say let's drop them for now, we can easily add them later on in the context
of an actual user.
next prev parent reply other threads:[~2025-07-02 18:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 14:34 [PATCH v11 0/4] rust: platform: add Io support Daniel Almeida
2025-07-01 14:34 ` [PATCH v11 1/4] rust: io: add resource abstraction Daniel Almeida
2025-07-02 7:44 ` Miguel Ojeda
2025-07-02 18:04 ` Daniel Almeida
2025-07-02 10:21 ` Danilo Krummrich
2025-07-02 18:11 ` Daniel Almeida
2025-07-02 18:16 ` Danilo Krummrich [this message]
2025-07-01 14:34 ` [PATCH v11 2/4] rust: io: mem: add a generic iomem abstraction Daniel Almeida
2025-07-01 14:34 ` [PATCH v11 3/4] rust: platform: add resource accessors Daniel Almeida
2025-07-01 14:34 ` [PATCH v11 4/4] rust: platform: allow ioremap of platform resources Daniel Almeida
2025-07-02 10:36 ` Danilo Krummrich
2025-07-02 7:52 ` [PATCH v11 0/4] rust: platform: add Io support Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aGV3ce3ZJEOanSMJ@pollux \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=huang.ying.caritas@gmail.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=me@kloenk.dev \
--cc=mika.westerberg@linux.intel.com \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).