[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLggjAu+YPBxJh0_K933McnnSC=pEBhVV9YxMbUGzukE3ng@mail.gmail.com>
Date: Mon, 13 Jan 2025 15:42:06 +0100
From: Alice Ryhl <aliceryhl@...gle.com>
To: Daniel Almeida <daniel.almeida@...labora.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org
Subject: Re: [PATCH] rust: irq: add support for request_irq()
On Thu, Oct 24, 2024 at 4:20 PM Daniel Almeida
<daniel.almeida@...labora.com> wrote:
>
> +impl<T: Handler> Registration<T> {
> + /// Registers the IRQ handler with the system for the given IRQ number. The
> + /// handler must be able to be called as soon as this function returns.
> + pub fn register(
> + irq: u32,
> + flags: Flags,
> + name: &'static CStr,
> + handler: T,
> + ) -> impl PinInit<Self, Error> {
> + try_pin_init!(Self {
> + irq,
> + handler: Opaque::new(handler)
> + })
> + .pin_chain(move |slot| {
> + // SAFETY:
> + // - `handler` points to a valid function defined below.
> + // - only valid flags can be constructed using the `flags` module.
> + // - `devname` is a nul-terminated string with a 'static lifetime.
> + // - `ptr` is a cookie used to identify the handler. The same cookie is
> + // passed back when the system calls the handler.
> + to_result(unsafe {
> + bindings::request_irq(
> + irq,
> + Some(handle_irq_callback::<T>),
> + flags.0,
> + name.as_char_ptr(),
> + &*slot as *const _ as *mut core::ffi::c_void,
> + )
> + })?;
> +
> + Ok(())
> + })
I think this does not run the destructor of `handler` when
`request_irq` returns an error.
Alice
Powered by blists - more mailing lists