On Wed Feb 25, 2026 at 7:27 AM JST, Joel Fernandes wrote: > Add a new module `clist` for working with C's doubly circular linked > lists. Provide low-level iteration over list nodes. > > Typed iteration over actual items is provided with a `clist_create` > macro to assist in creation of the `CList` type. > > Cc: Nikola Djukic <[email protected]> > Reviewed-by: Daniel Almeida <[email protected]> > Acked-by: Gary Guo <[email protected]> > Signed-off-by: Joel Fernandes <[email protected]>
Reviewed-by: Alexandre Courbot <[email protected]> (with one small comment below) > --- > MAINTAINERS | 8 + > rust/helpers/helpers.c | 1 + > rust/helpers/list.c | 17 ++ > rust/kernel/ffi/clist.rs | 338 +++++++++++++++++++++++++++++++++++++++ > rust/kernel/ffi/mod.rs | 2 + > rust/kernel/lib.rs | 1 + > 6 files changed, 367 insertions(+) > create mode 100644 rust/helpers/list.c > create mode 100644 rust/kernel/ffi/clist.rs > > diff --git a/MAINTAINERS b/MAINTAINERS > index dc82a6bd1a61..0dc318c94c99 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -23181,6 +23181,14 @@ T: git https://github.com/Rust-for-Linux/linux.git > alloc-next > F: rust/kernel/alloc.rs > F: rust/kernel/alloc/ > > +RUST [FFI HELPER] > +M: Joel Fernandes <[email protected]> (CLIST) > +M: Alexandre Courbot <[email protected]> (CLIST) > +L: [email protected] > +S: Maintained > +T: git https://github.com/Rust-for-Linux/linux.git ffi-next > +F: rust/kernel/ffi/ Acked-by: Alexandre Courbot <[email protected]> <snip> > +impl<'a, T, const OFFSET: usize> Iterator for CListIter<'a, T, OFFSET> { > + type Item = &'a T; > + > + #[inline] > + fn next(&mut self) -> Option<Self::Item> { > + let head = self.head_iter.next()?; > + > + // Convert to item using OFFSET. > + // SAFETY: `item_ptr` calculation from `OFFSET` (calculated using > offset_of!) `item_ptr` does not exist.
