[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aGliKRLJWfTs6rg0@cassiopeiae>
Date: Sat, 5 Jul 2025 19:34:33 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Daniel Almeida <daniel.almeida@...labora.com>
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
Subject: Re: [PATCH v12 3/3] rust: platform: add resource accessors
On Fri, Jul 04, 2025 at 01:25:28PM -0300, Daniel Almeida wrote:
> +impl Device<Bound> {
> + /// Returns an `IoRequest` for the resource at `index`, if any.
> + pub fn request_io_by_index(&self, index: u32) -> Option<IoRequest<'_>> {
> + // SAFETY: `resource` is a valid resource for `&self` during the
> + // lifetime of the `IoRequest`.
> + self.resource_by_index(index)
> + .map(|resource| unsafe { IoRequest::new(self.as_ref(), resource) })
> + }
> +
> + /// Returns an `IoRequest` for the resource with a given `name`, if any.
> + pub fn request_io_by_name(&self, name: &CStr) -> Option<IoRequest<'_>> {
> + // SAFETY: `resource` is a valid resource for `&self` during the
> + // lifetime of the `IoRequest`.
> + self.resource_by_name(name)
> + .map(|resource| unsafe { IoRequest::new(self.as_ref(), resource) })
> + }
> }
I think we should name this io_request_by_index() and io_request_by_name()
instead. We're not requesting to remap I/O memory (yet), but trying get an
IoRequest instance, hence I think this order fits better.
Powered by blists - more mailing lists