From nobody Fri Apr 3 08:02:48 2026 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76A6C2701B1 for ; Thu, 19 Feb 2026 09:12:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771492372; cv=none; b=OLIDQKA3PlhH+XwUYDmjx326jdmeUQ9SnEFGM3JdVdxKzVdTYzWcViTH7xwH8LpzaJAxEH9oSDVdV1etGzjVTPY8WRXoopS1qt5okANI/nHSIXb+vKSScvVoai+uAUc0hVRwqW6UDLNq2Antmm0VNO65sNziX86HLfAfZpn7IkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771492372; c=relaxed/simple; bh=Q2rgAjRF5CvFNzYLCneddbRD6VFtQfDTRv6rSB/gzvM=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=J/eO99PLWsbT1yV00tDUf6jJnS9DIcfXaX9H52uPsTLFvs4LewOYJNE+dnG7Vc8lw3UUZw2qpkFBseKxYLqf7wmOBNTxrceuLhV0B8ftWGgS/CkQmy2ivGRMkHWDq7xcq/8Xbt0JIPjTdEOs2/Nm1l+FzPLlLLwEZPq9kMWs3LI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KSgWTKW7; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KSgWTKW7" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4830e7c6131so8096205e9.2 for ; Thu, 19 Feb 2026 01:12:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771492370; x=1772097170; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=pAt84zPZh98Hp08Wh2JelC8rMXH5JkYVh+3oA6R0lvA=; b=KSgWTKW7YQXfMC6F1co5myDdonDHlQ3cqxgBcVeaEFUqamEv8PZc9mwK9slIS9YZmG nhVeXLgU+VGFBnO5WEdErjMRSVejyH3n2iIrPY1KK5a8AlvCFHOkGIxazjG7OUX/+tIv dY4pjUwfAo6fTxfPKoeIyXaLTvEcjNzFYr3Sho02DLnfGznRfLVBlYHmkRglqLibTtVt yo9A3fwKL3Mt6XANxm+Z+h5sgMaRPIkdUn8O1ylii654v4MfLeICWIsNKPStkk/cSPnx 9UfXrGOm0axK8B1b4wV1d4FoAGXY3NIf7yE68xBSjr8GP/r92YFqfNQ8ByPL/oRtJqHu 6azw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771492370; x=1772097170; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=pAt84zPZh98Hp08Wh2JelC8rMXH5JkYVh+3oA6R0lvA=; b=ig7zJ6apF80u7bqqUkH/LCqIsnBh1BksbPIVUDkRxWkuIy5vFu8ldtzTyuCanP5yMd 3gMG0GcojbX6JBTGnOvIQyt9MN8/DNXMWd+agJj1CElOGF4dksXrKnjN5yr/ok8kd6mX g2WmS+xjBXVHlnaLEZmlZwUq4LqJjwUFpAZsyvX/XCD8YrWguRd4p3MHxos1wa83FzZa IGP4dO/uaA8UxSNo3Cz8IsEpN9jndJO0Y9nzWf6qkWJ38nPEP+rpF5b/+0HUQp4WB7lt KWNlgaaLkDKC/QccvMktXPLnhGKMHq/o4L3RMMJRBTk7wLQkhm+hSXveu49DJEOjQoZ6 mLkA== X-Forwarded-Encrypted: i=1; AJvYcCWkn20u4dLi87YQ5q5gpZ4Mf9om7gesuL+HEGzT9Ed2tlno+55p4D8gC7uYhB0O1+u/4+KXjAHQPw+FKdQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwkURSTp6iFB63NuFUVLnoTuhTjRpdKGoLvVvcW07Xk9CKVGwjb 8EnJmjfGeV8sAX9cAj8v1C4ktyfc5DmqfUl7QwPwjgVCVSA3nkziGa5Ydp5eK7BOBEMNdCSJnYz XosrK2XdDJFR1CGhrBQ== X-Received: from wmop6.prod.google.com ([2002:a05:600c:4686:b0:483:6e65:5bb9]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:820f:b0:483:71f7:2797 with SMTP id 5b1f17b1804b1-48379b9f3a3mr285166695e9.14.1771492369552; Thu, 19 Feb 2026 01:12:49 -0800 (PST) Date: Thu, 19 Feb 2026 09:12:29 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAPzTlmkC/x3MPQqAMAxA4auUzAa0/hS9ijjUGjVL1bSIIL27x fEb3nshkDAFGNQLQjcHPnxGVShwu/UbIS/ZoEvdlbrqkeXCEG1kh4fHKJYjtrPujDO2qU0LuTy FVn7+6zil9AGynHvEZQAAAA== X-Change-Id: 20260219-irq-static-on-trait-5b267c7a4375 X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=5282; i=aliceryhl@google.com; h=from:subject:message-id; bh=Q2rgAjRF5CvFNzYLCneddbRD6VFtQfDTRv6rSB/gzvM=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBpltQAp42kJM1DIWmIxMTreepBnlW5qszAySh10 UVpGu/KgmSJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCaZbUAAAKCRAEWL7uWMY5 Rk8UEACJx1pL9EcxkJzlHpMdLS7H39F9cAtrVpZ7fBXDHoly17Om7QIe61FWw8O9aYElA07f6kl eN/1K3u6dS4ihTlIZS8tC+ru2xRrGTlYOFw/HKgWfkoUrWGO4KVHuj0Ft77kd58eqSFZ2QqPIrJ XflhVi7UUo+LgWs3sb5r8xeVKXDnaQ5ovdjuAzx6BVnjRZYF0G6nluGf8dgz9Vgx5vddzNhtbqk hUwpTQm1u/SSaCF70h2HkTBo39/Ndc/jweYOs7ucRxKuS5CsMqd041ZkyUiQim9SpoH+QqXNETS RM7OAlz5QdG5k3jrbaaE2QCin2VB0J7F0bHHx8ZTLdPMtrs70vqczR9E0XHZCBtPe9mKya+7Diw n6JynfdPh9KlVkrAHFso6G0E4PlAks+5gIwRDCZOUJ0vEpE00NA7fcK3P8CWRyrTEkdrbhX53o5 fM8uyw6M8ZIPuZlhVlqoDZ63poH+7iZwBZBDD2sjKGBUNSBkqOsAvEoGs5KhjIlOb+8yoOpcKzG Ka+77F5rLBymODv7Ogtbd1Hs45IqQi6sW5rgO6Yd50S4MBnpUrYHbTnthGBZpoKsBVAV4OjelRb T1Ou7CfIpsZsrQMPdnsKq+Ec97Ealc4UAQPtftyIQx/aKHFHdtbDL4kcMLu0Q5q1aeUCaYS/2cg l022VyQfFxz/ccA== X-Mailer: b4 0.14.2 Message-ID: <20260219-irq-static-on-trait-v1-1-6ede6b743ea3@google.com> Subject: [PATCH] rust: irq: move 'static bounds to traits From: Alice Ryhl To: Danilo Krummrich , Daniel Almeida , Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Trevor Gross Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Alice Ryhl Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: Benno Lossin Reviewed-by: Gary Guo --- 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..e207707156094b1bbf1af0292cf= f8ed27ea64207 100644 --- a/rust/kernel/irq/request.rs +++ b/rust/kernel/irq/request.rs @@ -27,7 +27,7 @@ pub enum IrqReturn { } =20 /// 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) -> IrqReturn { } } =20 -impl Handler for Box { +impl Handler for Box { fn handle(&self, device: &Device) -> 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 { +pub struct Registration { #[pin] inner: Devres, =20 @@ -195,7 +195,7 @@ pub struct Registration { _pin: PhantomPinned, } =20 -impl Registration { +impl Registration { /// 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) -> Resu= lt { /// # 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 `Registratio= n::new` let registration =3D unsafe { &*(ptr as *const Registration) }; // SAFETY: The irq callback is removed before the device is unbound, s= o the fact that the irq @@ -288,7 +285,7 @@ pub enum ThreadedIrqReturn { } =20 /// 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) -> Ir= qReturn { } } =20 -impl ThreadedHandler for Box { +impl ThreadedHandler = for Box { fn handle(&self, device: &Device) -> ThreadedIrqReturn { T::handle(self, device) } @@ -403,7 +400,7 @@ fn handle_threaded(&self, device: &Device) -> Ir= qReturn { /// /// * We own an irq handler whose cookie is a pointer to `Self`. #[pin_data] -pub struct ThreadedRegistration { +pub struct ThreadedRegistration { #[pin] inner: Devres, =20 @@ -416,7 +413,7 @@ pub struct ThreadedRegistration { _pin: PhantomPinned, } =20 -impl ThreadedRegistration { +impl ThreadedRegistration { /// 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) -> Resul= t { /// # 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 { @@ -499,10 +496,7 @@ pub fn synchronize(&self, dev: &Device) -> Resu= lt { /// # 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 `Thr= eadedRegistration::new` let registration =3D unsafe { &*(ptr as *const ThreadedRegistration= ) }; // SAFETY: The irq callback is removed before the device is unbound, s= o the fact that the irq --- base-commit: a58b8764aed9648357b1c5b6368c9943ba33b7f9 change-id: 20260219-irq-static-on-trait-5b267c7a4375 Best regards, --=20 Alice Ryhl