Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

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>

+12 -8
+12 -8
rust/kernel/pci/irq.rs
··· 175 175 flags: irq::Flags, 176 176 name: &'static CStr, 177 177 handler: impl PinInit<T, Error> + 'a, 178 - ) -> Result<impl PinInit<irq::Registration<T>, Error> + 'a> { 179 - let request = vector.try_into()?; 178 + ) -> impl PinInit<irq::Registration<T>, Error> + 'a { 179 + pin_init::pin_init_scope(move || { 180 + let request = vector.try_into()?; 180 181 181 - Ok(irq::Registration::<T>::new(request, flags, name, handler)) 182 + Ok(irq::Registration::<T>::new(request, flags, name, handler)) 183 + }) 182 184 } 183 185 184 186 /// Returns a [`kernel::irq::ThreadedRegistration`] for the given IRQ vector. ··· 190 188 flags: irq::Flags, 191 189 name: &'static CStr, 192 190 handler: impl PinInit<T, Error> + 'a, 193 - ) -> Result<impl PinInit<irq::ThreadedRegistration<T>, Error> + 'a> { 194 - let request = vector.try_into()?; 191 + ) -> impl PinInit<irq::ThreadedRegistration<T>, Error> + 'a { 192 + pin_init::pin_init_scope(move || { 193 + let request = vector.try_into()?; 195 194 196 - Ok(irq::ThreadedRegistration::<T>::new( 197 - request, flags, name, handler, 198 - )) 195 + Ok(irq::ThreadedRegistration::<T>::new( 196 + request, flags, name, handler, 197 + )) 198 + }) 199 199 } 200 200 201 201 /// Allocate IRQ vectors for this PCI device with automatic cleanup.