[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251103203053.2348783-1-dakr@kernel.org>
Date: Mon, 3 Nov 2025 21:30:12 +0100
From: Danilo Krummrich <dakr@...nel.org>
To: bhelgaas@...gle.com,
kwilczynski@...nel.org,
gregkh@...uxfoundation.org,
rafael@...nel.org,
ojeda@...nel.org,
alex.gaynor@...il.com,
boqun.feng@...il.com,
gary@...yguo.net,
bjorn3_gh@...tonmail.com,
lossin@...nel.org,
a.hindborg@...nel.org,
aliceryhl@...gle.com,
tmgross@...ch.edu
Cc: linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org,
rust-for-linux@...r.kernel.org,
Danilo Krummrich <dakr@...nel.org>
Subject: [PATCH 1/2] rust: pci: get rid of redundant Result in IRQ methods
Currently request_irq() returns
Result<impl PinInit<irq::Registration<T>, Error> + 'a>
which may carry an error in the Result or the initializer; the same is
true for request_threaded_irq().
Use pin_init::pin_init_scope() to get rid of this redundancy.
Signed-off-by: Danilo Krummrich <dakr@...nel.org>
---
rust/kernel/pci/irq.rs | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/rust/kernel/pci/irq.rs b/rust/kernel/pci/irq.rs
index 782a524fe11c..03f2de559a8a 100644
--- a/rust/kernel/pci/irq.rs
+++ b/rust/kernel/pci/irq.rs
@@ -175,10 +175,12 @@ pub fn request_irq<'a, T: crate::irq::Handler + 'static>(
flags: irq::Flags,
name: &'static CStr,
handler: impl PinInit<T, Error> + 'a,
- ) -> Result<impl PinInit<irq::Registration<T>, Error> + 'a> {
- let request = vector.try_into()?;
+ ) -> impl PinInit<irq::Registration<T>, Error> + 'a {
+ pin_init::pin_init_scope(move || {
+ let request = vector.try_into()?;
- Ok(irq::Registration::<T>::new(request, flags, name, handler))
+ Ok(irq::Registration::<T>::new(request, flags, name, handler))
+ })
}
/// Returns a [`kernel::irq::ThreadedRegistration`] for the given IRQ vector.
@@ -188,12 +190,14 @@ pub fn request_threaded_irq<'a, T: crate::irq::ThreadedHandler + 'static>(
flags: irq::Flags,
name: &'static CStr,
handler: impl PinInit<T, Error> + 'a,
- ) -> Result<impl PinInit<irq::ThreadedRegistration<T>, Error> + 'a> {
- let request = vector.try_into()?;
-
- Ok(irq::ThreadedRegistration::<T>::new(
- request, flags, name, handler,
- ))
+ ) -> impl PinInit<irq::ThreadedRegistration<T>, Error> + 'a {
+ pin_init::pin_init_scope(move || {
+ let request = vector.try_into()?;
+
+ Ok(irq::ThreadedRegistration::<T>::new(
+ request, flags, name, handler,
+ ))
+ })
}
/// Allocate IRQ vectors for this PCI device with automatic cleanup.
--
2.51.0
Powered by blists - more mailing lists