From: Gary Guo <gary@garyguo.net>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: irq: move 'static bounds to traits
Date: Thu, 19 Feb 2026 14:44:22 +0000 [thread overview]
Message-ID: <7442f2b32fb502cca25d61df390021dd@garyguo.net> (raw)
In-Reply-To: <20260219-irq-static-on-trait-v1-1-6ede6b743ea3@google.com>
On 2026-02-19 09:12, Alice Ryhl wrote:
> The 'static bound is required by all irq handlers, so it is simpler to
> specify it on the trait declaration instead of repeating it every time
> the trait is used as a where clause. Note that we already list Sync on
> the trait bound for the same reason.
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Thanks, this is much cleaner.
Reviewed-by: Gary Guo <gary@garyguo.net>
Best,
Gary
> ---
> Follow up to:
> https://lore.kernel.org/all/20260214092740.3201946-1-lossin@kernel.org/
> ---
> rust/kernel/irq/request.rs | 28 +++++++++++-----------------
> 1 file changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/rust/kernel/irq/request.rs b/rust/kernel/irq/request.rs
> index
> 2ceeaeb0543a4ef0d4f25ca600dc4770f97085c5..e207707156094b1bbf1af0292cff8ed27ea64207
> 100644
> --- a/rust/kernel/irq/request.rs
> +++ b/rust/kernel/irq/request.rs
> @@ -27,7 +27,7 @@ pub enum IrqReturn {
> }
>
> /// Callbacks for an IRQ handler.
> -pub trait Handler: Sync {
> +pub trait Handler: Sync + 'static {
> /// The hard IRQ handler.
> ///
> /// This is executed in interrupt context, hence all corresponding
> @@ -45,7 +45,7 @@ fn handle(&self, device: &Device<Bound>) -> IrqReturn
> {
> }
> }
>
> -impl<T: ?Sized + Handler, A: Allocator> Handler for Box<T, A> {
> +impl<T: ?Sized + Handler, A: Allocator + 'static> Handler for Box<T,
> A> {
> fn handle(&self, device: &Device<Bound>) -> IrqReturn {
> T::handle(self, device)
> }
> @@ -182,7 +182,7 @@ pub fn irq(&self) -> u32 {
> ///
> /// * We own an irq handler whose cookie is a pointer to `Self`.
> #[pin_data]
> -pub struct Registration<T: Handler + 'static> {
> +pub struct Registration<T: Handler> {
> #[pin]
> inner: Devres<RegistrationInner>,
>
> @@ -195,7 +195,7 @@ pub struct Registration<T: Handler + 'static> {
> _pin: PhantomPinned,
> }
>
> -impl<T: Handler + 'static> Registration<T> {
> +impl<T: Handler> Registration<T> {
> /// Registers the IRQ handler with the system for the given IRQ
> number.
> pub fn new<'a>(
> request: IrqRequest<'a>,
> @@ -261,10 +261,7 @@ pub fn synchronize(&self, dev: &Device<Bound>) ->
> Result {
> /// # Safety
> ///
> /// This function should be only used as the callback in
> `request_irq`.
> -unsafe extern "C" fn handle_irq_callback<T: Handler + 'static>(
> - _irq: i32,
> - ptr: *mut c_void,
> -) -> c_uint {
> +unsafe extern "C" fn handle_irq_callback<T: Handler>(_irq: i32, ptr:
> *mut c_void) -> c_uint {
> // SAFETY: `ptr` is a pointer to `Registration<T>` set in
> `Registration::new`
> let registration = unsafe { &*(ptr as *const Registration<T>) };
> // SAFETY: The irq callback is removed before the device is
> unbound, so the fact that the irq
> @@ -288,7 +285,7 @@ pub enum ThreadedIrqReturn {
> }
>
> /// Callbacks for a threaded IRQ handler.
> -pub trait ThreadedHandler: Sync {
> +pub trait ThreadedHandler: Sync + 'static {
> /// The hard IRQ handler.
> ///
> /// This is executed in interrupt context, hence all corresponding
> @@ -319,7 +316,7 @@ fn handle_threaded(&self, device: &Device<Bound>)
> -> IrqReturn {
> }
> }
>
> -impl<T: ?Sized + ThreadedHandler, A: Allocator> ThreadedHandler for
> Box<T, A> {
> +impl<T: ?Sized + ThreadedHandler, A: Allocator + 'static>
> ThreadedHandler for Box<T, A> {
> fn handle(&self, device: &Device<Bound>) -> ThreadedIrqReturn {
> T::handle(self, device)
> }
> @@ -403,7 +400,7 @@ fn handle_threaded(&self, device: &Device<Bound>)
> -> IrqReturn {
> ///
> /// * We own an irq handler whose cookie is a pointer to `Self`.
> #[pin_data]
> -pub struct ThreadedRegistration<T: ThreadedHandler + 'static> {
> +pub struct ThreadedRegistration<T: ThreadedHandler> {
> #[pin]
> inner: Devres<RegistrationInner>,
>
> @@ -416,7 +413,7 @@ pub struct ThreadedRegistration<T: ThreadedHandler
> + 'static> {
> _pin: PhantomPinned,
> }
>
> -impl<T: ThreadedHandler + 'static> ThreadedRegistration<T> {
> +impl<T: ThreadedHandler> ThreadedRegistration<T> {
> /// Registers the IRQ handler with the system for the given IRQ
> number.
> pub fn new<'a>(
> request: IrqRequest<'a>,
> @@ -483,7 +480,7 @@ pub fn synchronize(&self, dev: &Device<Bound>) ->
> Result {
> /// # Safety
> ///
> /// This function should be only used as the callback in
> `request_threaded_irq`.
> -unsafe extern "C" fn handle_threaded_irq_callback<T: ThreadedHandler +
> 'static>(
> +unsafe extern "C" fn handle_threaded_irq_callback<T: ThreadedHandler>(
> _irq: i32,
> ptr: *mut c_void,
> ) -> c_uint {
> @@ -499,10 +496,7 @@ pub fn synchronize(&self, dev: &Device<Bound>) ->
> Result {
> /// # Safety
> ///
> /// This function should be only used as the callback in
> `request_threaded_irq`.
> -unsafe extern "C" fn thread_fn_callback<T: ThreadedHandler + 'static>(
> - _irq: i32,
> - ptr: *mut c_void,
> -) -> c_uint {
> +unsafe extern "C" fn thread_fn_callback<T: ThreadedHandler>(_irq: i32,
> ptr: *mut c_void) -> c_uint {
> // SAFETY: `ptr` is a pointer to `ThreadedRegistration<T>` set in
> `ThreadedRegistration::new`
> let registration = unsafe { &*(ptr as *const
> ThreadedRegistration<T>) };
> // SAFETY: The irq callback is removed before the device is
> unbound, so the fact that the irq
>
> ---
> base-commit: a58b8764aed9648357b1c5b6368c9943ba33b7f9
> change-id: 20260219-irq-static-on-trait-5b267c7a4375
>
> Best regards,
next prev parent reply other threads:[~2026-02-19 14:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 9:12 Alice Ryhl
2026-02-19 14:44 ` Gary Guo [this message]
2026-02-19 15:47 ` Benno Lossin
2026-03-03 19:55 ` Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7442f2b32fb502cca25d61df390021dd@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®