Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20260219-irq-static-on-trait-v1-1-6ede6b743ea3@google.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

Alice Ryhl and committed by
Danilo Krummrich
d1880d5f 1b9a5bc8

+11 -17
+11 -17
rust/kernel/irq/request.rs
··· 27 27 } 28 28 29 29 /// Callbacks for an IRQ handler. 30 - pub trait Handler: Sync { 30 + pub trait Handler: Sync + 'static { 31 31 /// The hard IRQ handler. 32 32 /// 33 33 /// This is executed in interrupt context, hence all corresponding ··· 45 45 } 46 46 } 47 47 48 - impl<T: ?Sized + Handler, A: Allocator> Handler for Box<T, A> { 48 + impl<T: ?Sized + Handler, A: Allocator + 'static> Handler for Box<T, A> { 49 49 fn handle(&self, device: &Device<Bound>) -> IrqReturn { 50 50 T::handle(self, device) 51 51 } ··· 181 181 /// 182 182 /// * We own an irq handler whose cookie is a pointer to `Self`. 183 183 #[pin_data] 184 - pub struct Registration<T: Handler + 'static> { 184 + pub struct Registration<T: Handler> { 185 185 #[pin] 186 186 inner: Devres<RegistrationInner>, 187 187 ··· 194 194 _pin: PhantomPinned, 195 195 } 196 196 197 - impl<T: Handler + 'static> Registration<T> { 197 + impl<T: Handler> Registration<T> { 198 198 /// Registers the IRQ handler with the system for the given IRQ number. 199 199 pub fn new<'a>( 200 200 request: IrqRequest<'a>, ··· 260 260 /// # Safety 261 261 /// 262 262 /// This function should be only used as the callback in `request_irq`. 263 - unsafe extern "C" fn handle_irq_callback<T: Handler + 'static>( 264 - _irq: i32, 265 - ptr: *mut c_void, 266 - ) -> c_uint { 263 + unsafe extern "C" fn handle_irq_callback<T: Handler>(_irq: i32, ptr: *mut c_void) -> c_uint { 267 264 // SAFETY: `ptr` is a pointer to `Registration<T>` set in `Registration::new` 268 265 let registration = unsafe { &*(ptr as *const Registration<T>) }; 269 266 // SAFETY: The irq callback is removed before the device is unbound, so the fact that the irq ··· 284 287 } 285 288 286 289 /// Callbacks for a threaded IRQ handler. 287 - pub trait ThreadedHandler: Sync { 290 + pub trait ThreadedHandler: Sync + 'static { 288 291 /// The hard IRQ handler. 289 292 /// 290 293 /// This is executed in interrupt context, hence all corresponding ··· 315 318 } 316 319 } 317 320 318 - impl<T: ?Sized + ThreadedHandler, A: Allocator> ThreadedHandler for Box<T, A> { 321 + impl<T: ?Sized + ThreadedHandler, A: Allocator + 'static> ThreadedHandler for Box<T, A> { 319 322 fn handle(&self, device: &Device<Bound>) -> ThreadedIrqReturn { 320 323 T::handle(self, device) 321 324 } ··· 398 401 /// 399 402 /// * We own an irq handler whose cookie is a pointer to `Self`. 400 403 #[pin_data] 401 - pub struct ThreadedRegistration<T: ThreadedHandler + 'static> { 404 + pub struct ThreadedRegistration<T: ThreadedHandler> { 402 405 #[pin] 403 406 inner: Devres<RegistrationInner>, 404 407 ··· 411 414 _pin: PhantomPinned, 412 415 } 413 416 414 - impl<T: ThreadedHandler + 'static> ThreadedRegistration<T> { 417 + impl<T: ThreadedHandler> ThreadedRegistration<T> { 415 418 /// Registers the IRQ handler with the system for the given IRQ number. 416 419 pub fn new<'a>( 417 420 request: IrqRequest<'a>, ··· 478 481 /// # Safety 479 482 /// 480 483 /// This function should be only used as the callback in `request_threaded_irq`. 481 - unsafe extern "C" fn handle_threaded_irq_callback<T: ThreadedHandler + 'static>( 484 + unsafe extern "C" fn handle_threaded_irq_callback<T: ThreadedHandler>( 482 485 _irq: i32, 483 486 ptr: *mut c_void, 484 487 ) -> c_uint { ··· 494 497 /// # Safety 495 498 /// 496 499 /// This function should be only used as the callback in `request_threaded_irq`. 497 - unsafe extern "C" fn thread_fn_callback<T: ThreadedHandler + 'static>( 498 - _irq: i32, 499 - ptr: *mut c_void, 500 - ) -> c_uint { 500 + unsafe extern "C" fn thread_fn_callback<T: ThreadedHandler>(_irq: i32, ptr: *mut c_void) -> c_uint { 501 501 // SAFETY: `ptr` is a pointer to `ThreadedRegistration<T>` set in `ThreadedRegistration::new` 502 502 let registration = unsafe { &*(ptr as *const ThreadedRegistration<T>) }; 503 503 // SAFETY: The irq callback is removed before the device is unbound, so the fact that the irq