1
0

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>
This commit is contained in:
Danilo Krummrich
2025-11-03 21:30:13 +01:00
parent 1f7b01661f
commit b892ed360d

View File

@@ -301,15 +301,17 @@ macro_rules! define_irq_accessor_by_index {
index: u32,
name: &'static CStr,
handler: impl PinInit<T, Error> + 'a,
) -> Result<impl PinInit<irq::$reg_type<T>, Error> + 'a> {
let request = self.$request_fn(index)?;
) -> impl PinInit<irq::$reg_type<T>, Error> + 'a {
pin_init::pin_init_scope(move || {
let request = self.$request_fn(index)?;
Ok(irq::$reg_type::<T>::new(
request,
flags,
name,
handler,
))
Ok(irq::$reg_type::<T>::new(
request,
flags,
name,
handler,
))
})
}
};
}
@@ -325,18 +327,20 @@ macro_rules! define_irq_accessor_by_name {
pub fn $fn_name<'a, T: irq::$handler_trait + 'static>(
&'a self,
flags: irq::Flags,
irq_name: &CStr,
irq_name: &'a CStr,
name: &'static CStr,
handler: impl PinInit<T, Error> + 'a,
) -> Result<impl PinInit<irq::$reg_type<T>, Error> + 'a> {
let request = self.$request_fn(irq_name)?;
) -> impl PinInit<irq::$reg_type<T>, Error> + 'a {
pin_init::pin_init_scope(move || {
let request = self.$request_fn(irq_name)?;
Ok(irq::$reg_type::<T>::new(
request,
flags,
name,
handler,
))
Ok(irq::$reg_type::<T>::new(
request,
flags,
name,
handler,
))
})
}
};
}