]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: pci: get rid of redundant Result in IRQ methods
authorDanilo Krummrich <dakr@kernel.org>
Mon, 3 Nov 2025 20:30:12 +0000 (21:30 +0100)
committerDanilo Krummrich <dakr@kernel.org>
Thu, 6 Nov 2025 09:19:36 +0000 (10:19 +0100)
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.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20251103203053.2348783-1-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/pci/irq.rs

index 782a524fe11c0b951dfd8613273235953d92db24..03f2de559a8a404b41252849181443a6ab78d910 100644 (file)
@@ -175,10 +175,12 @@ impl Device<device::Bound> {
         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 @@ impl Device<device::Bound> {
         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.