From: Alice Ryhl Date: Thu, 19 Feb 2026 09:12:29 +0000 (+0000) Subject: rust: irq: move 'static bounds to traits X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1880d5f5899c572337ceb3d7e067052b22597e1;p=thirdparty%2Fkernel%2Flinux.git rust: irq: move 'static bounds to traits 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 Reviewed-by: Gary Guo Reviewed-by: Benno Lossin Link: https://patch.msgid.link/20260219-irq-static-on-trait-v1-1-6ede6b743ea3@google.com Signed-off-by: Danilo Krummrich --- diff --git a/rust/kernel/irq/request.rs b/rust/kernel/irq/request.rs index 7a36f790593e1..f425fe12f7c82 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 @@ impl Handler for Arc { } } -impl Handler for Box { +impl Handler for Box { fn handle(&self, device: &Device) -> IrqReturn { T::handle(self, device) } @@ -181,7 +181,7 @@ impl<'a> IrqRequest<'a> { /// /// * We own an irq handler whose cookie is a pointer to `Self`. #[pin_data] -pub struct Registration { +pub struct Registration { #[pin] inner: Devres, @@ -194,7 +194,7 @@ pub struct Registration { _pin: PhantomPinned, } -impl Registration { +impl Registration { /// Registers the IRQ handler with the system for the given IRQ number. pub fn new<'a>( request: IrqRequest<'a>, @@ -260,10 +260,7 @@ impl Registration { /// # Safety /// /// This function should be only used as the callback in `request_irq`. -unsafe extern "C" fn handle_irq_callback( - _irq: i32, - ptr: *mut c_void, -) -> c_uint { +unsafe extern "C" fn handle_irq_callback(_irq: i32, ptr: *mut c_void) -> c_uint { // SAFETY: `ptr` is a pointer to `Registration` set in `Registration::new` let registration = unsafe { &*(ptr as *const Registration) }; // SAFETY: The irq callback is removed before the device is unbound, so the fact that the irq @@ -287,7 +284,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 @@ -318,7 +315,7 @@ impl ThreadedHandler for Arc { } } -impl ThreadedHandler for Box { +impl ThreadedHandler for Box { fn handle(&self, device: &Device) -> ThreadedIrqReturn { T::handle(self, device) } @@ -401,7 +398,7 @@ impl ThreadedHandler for Box { /// /// * We own an irq handler whose cookie is a pointer to `Self`. #[pin_data] -pub struct ThreadedRegistration { +pub struct ThreadedRegistration { #[pin] inner: Devres, @@ -414,7 +411,7 @@ pub struct ThreadedRegistration { _pin: PhantomPinned, } -impl ThreadedRegistration { +impl ThreadedRegistration { /// Registers the IRQ handler with the system for the given IRQ number. pub fn new<'a>( request: IrqRequest<'a>, @@ -481,7 +478,7 @@ impl ThreadedRegistration { /// # Safety /// /// This function should be only used as the callback in `request_threaded_irq`. -unsafe extern "C" fn handle_threaded_irq_callback( +unsafe extern "C" fn handle_threaded_irq_callback( _irq: i32, ptr: *mut c_void, ) -> c_uint { @@ -497,10 +494,7 @@ unsafe extern "C" fn handle_threaded_irq_callback( /// # Safety /// /// This function should be only used as the callback in `request_threaded_irq`. -unsafe extern "C" fn thread_fn_callback( - _irq: i32, - ptr: *mut c_void, -) -> c_uint { +unsafe extern "C" fn thread_fn_callback(_irq: i32, ptr: *mut c_void) -> c_uint { // SAFETY: `ptr` is a pointer to `ThreadedRegistration` set in `ThreadedRegistration::new` let registration = unsafe { &*(ptr as *const ThreadedRegistration) }; // SAFETY: The irq callback is removed before the device is unbound, so the fact that the irq