Commit b892ed36 authored by Danilo Krummrich's avatar Danilo Krummrich
Browse files

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: default avatarAlice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20251103203053.2348783-2-dakr@kernel.org


Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent 1f7b0166
Loading
Loading
Loading
Loading
+23 −19
Original line number Diff line number Diff line
@@ -301,7 +301,8 @@ pub fn $fn_name<'a, T: irq::$handler_trait + 'static>(
            index: u32,
            name: &'static CStr,
            handler: impl PinInit<T, Error> + 'a,
        ) -> Result<impl PinInit<irq::$reg_type<T>, Error> + 'a> {
        ) -> 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(
@@ -310,6 +311,7 @@ pub fn $fn_name<'a, T: irq::$handler_trait + 'static>(
                    name,
                    handler,
                ))
            })
        }
    };
}
@@ -325,10 +327,11 @@ 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> {
        ) -> 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(
@@ -337,6 +340,7 @@ pub fn $fn_name<'a, T: irq::$handler_trait + 'static>(
                    name,
                    handler,
                ))
            })
        }
    };
}