[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <4DF66D6F-C89E-4472-AB76-B3EB1CB6F07C@collabora.com>
Date: Wed, 2 Jul 2025 15:11:04 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: 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>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Ying Huang <huang.ying.caritas@...il.com>,
Benno Lossin <lossin@...nel.org>,
linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org,
Fiona Behrens <me@...enk.dev>
Subject: Re: [PATCH v11 1/4] rust: io: add resource abstraction
Hi Danilo
> On 2 Jul 2025, at 07:21, Danilo Krummrich <dakr@...nel.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.
Fiona, do you still need these two accessors?
— Daniel
Powered by blists - more mailing lists