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: platform: get rid of redundant Result in IRQ methods

Currently request_irq_by_index() 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 the other IRQ methods.

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-2-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

+21 -17
+21 -17
rust/kernel/platform.rs
··· 301 301 index: u32, 302 302 name: &'static CStr, 303 303 handler: impl PinInit<T, Error> + 'a, 304 - ) -> Result<impl PinInit<irq::$reg_type<T>, Error> + 'a> { 305 - let request = self.$request_fn(index)?; 304 + ) -> impl PinInit<irq::$reg_type<T>, Error> + 'a { 305 + pin_init::pin_init_scope(move || { 306 + let request = self.$request_fn(index)?; 306 307 307 - Ok(irq::$reg_type::<T>::new( 308 - request, 309 - flags, 310 - name, 311 - handler, 312 - )) 308 + Ok(irq::$reg_type::<T>::new( 309 + request, 310 + flags, 311 + name, 312 + handler, 313 + )) 314 + }) 313 315 } 314 316 }; 315 317 } ··· 327 325 pub fn $fn_name<'a, T: irq::$handler_trait + 'static>( 328 326 &'a self, 329 327 flags: irq::Flags, 330 - irq_name: &CStr, 328 + irq_name: &'a CStr, 331 329 name: &'static CStr, 332 330 handler: impl PinInit<T, Error> + 'a, 333 - ) -> Result<impl PinInit<irq::$reg_type<T>, Error> + 'a> { 334 - let request = self.$request_fn(irq_name)?; 331 + ) -> impl PinInit<irq::$reg_type<T>, Error> + 'a { 332 + pin_init::pin_init_scope(move || { 333 + let request = self.$request_fn(irq_name)?; 335 334 336 - Ok(irq::$reg_type::<T>::new( 337 - request, 338 - flags, 339 - name, 340 - handler, 341 - )) 335 + Ok(irq::$reg_type::<T>::new( 336 + request, 337 + flags, 338 + name, 339 + handler, 340 + )) 341 + }) 342 342 } 343 343 }; 344 344 }