[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260128215330.58410-7-boqun.feng@gmail.com>
Date: Wed, 28 Jan 2026 13:53:29 -0800
From: Boqun Feng <boqun.feng@...il.com>
To: linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org,
rcu@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Arve Hjønnevåg <arve@...roid.com>,
Todd Kjos <tkjos@...roid.com>, Christian Brauner <brauner@...nel.org>,
Carlos Llamas <cmllamas@...gle.com>, Alice Ryhl <aliceryhl@...gle.com>,
Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>,
"Paul E. McKenney" <paulmck@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
Neeraj Upadhyay <neeraj.upadhyay@...nel.org>,
Joel Fernandes <joelagnelf@...dia.com>,
Josh Triplett <josh@...htriplett.org>,
Uladzislau Rezki <urezki@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>, Zqiang <qiang.zhang@...ux.dev>,
FUJITA Tomonori <fujita.tomonori@...il.com>,
Lyude Paul <lyude@...hat.com>, Thomas Gleixner <tglx@...nel.org>,
Anna-Maria Behnsen <anna-maria@...utronix.de>,
John Stultz <jstultz@...gle.com>, Stephen Boyd <sboyd@...nel.org>,
"Yury Norov (NVIDIA)" <yury.norov@...il.com>,
Vitaly Wool <vitaly.wool@...sulko.se>,
Tamir Duberstein <tamird@...nel.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
Daniel Almeida <daniel.almeida@...labora.com>,
Mitchell Levy <levymitchell0@...il.com>, David Gow <davidgow@...gle.com>,
Peter Novak <seimun018r@...il.com>,
José Expósito <jose.exposito89@...il.com>
Subject: [RFC PATCH 6/7] rust: work: Remove `impl_has_work!`
Now all in-tree users of `impl_has_work!()` are converted to use
`#[derive(HasField)]`, hence remove it.
Signed-off-by: Boqun Feng <boqun.feng@...il.com>
---
rust/kernel/workqueue.rs | 53 ++--------------------------------------
1 file changed, 2 insertions(+), 51 deletions(-)
diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
index 2dcfd3eace39..37fbf348c760 100644
--- a/rust/kernel/workqueue.rs
+++ b/rust/kernel/workqueue.rs
@@ -578,55 +578,6 @@ pub unsafe trait HasWork<T, const ID: u64 = 0> {
unsafe fn work_container_of(ptr: *mut Work<T, ID>) -> *mut Self;
}
-/// Used to safely implement the [`HasWork<T, ID>`] trait.
-///
-/// # Examples
-///
-/// ```
-/// use kernel::sync::Arc;
-/// use kernel::workqueue::{self, impl_has_work, Work};
-///
-/// struct MyStruct<'a, T, const N: usize> {
-/// work_field: Work<MyStruct<'a, T, N>, 17>,
-/// f: fn(&'a [T; N]),
-/// }
-///
-/// impl_has_work! {
-/// impl{'a, T, const N: usize} HasWork<MyStruct<'a, T, N>, 17>
-/// for MyStruct<'a, T, N> { self.work_field }
-/// }
-/// ```
-#[macro_export]
-macro_rules! impl_has_work {
- ($(impl$({$($generics:tt)*})?
- HasWork<$work_type:ty $(, $id:tt)?>
- for $self:ty
- { self.$field:ident }
- )*) => {$(
- // SAFETY: The implementation of `raw_get_work` only compiles if the field has the right
- // type.
- unsafe impl$(<$($generics)+>)? $crate::workqueue::HasWork<$work_type $(, $id)?> for $self {
- #[inline]
- unsafe fn raw_get_work(ptr: *mut Self) -> *mut $crate::workqueue::Work<$work_type $(, $id)?> {
- // SAFETY: The caller promises that the pointer is not dangling.
- unsafe {
- ::core::ptr::addr_of_mut!((*ptr).$field)
- }
- }
-
- #[inline]
- unsafe fn work_container_of(
- ptr: *mut $crate::workqueue::Work<$work_type $(, $id)?>,
- ) -> *mut Self {
- // SAFETY: The caller promises that the pointer points at a field of the right type
- // in the right kind of struct.
- unsafe { $crate::container_of!(ptr, Self, $field) }
- }
- }
- )*};
-}
-pub use impl_has_work;
-
impl<T, const ID: u64> Field<T> for Work<T, ID> {}
/// SAFETY: Per the safety requirement of `HasField`, `raw_get_field()` and `field_container_of()`
@@ -746,8 +697,8 @@ pub unsafe trait HasDelayedWork<T, const ID: u64 = 0>: HasWork<T, ID> {}
/// Used to safely implement the [`HasDelayedWork<T, ID>`] trait.
///
-/// This macro also implements the [`HasWork`] trait, so you do not need to use [`impl_has_work!`]
-/// when using this macro.
+/// This macro also implements the [`HasWork`] trait, so you do not need to use `#[has_field]` when
+/// using this macro.
///
/// # Examples
///
--
2.50.1 (Apple Git-155)
Powered by blists - more mailing lists