Re: [PATCH v2 4/4] rust: Move register and bitstruct macros out of Nova

Joel Fernandes
2025-09-08T20:14:15Z

On Mon, Sep 08, 2025 at 12:52:57PM +0900, Alexandre Courbot wrote:
> On Thu Sep 4, 2025 at 6:54 AM JST, Joel Fernandes wrote:
> > Out of broad need for these macros in Rust, move them out. Several folks
> > have shown interest (Nova, Tyr GPU drivers).
> >
> > bitstruct - defines bitfields in Rust structs similar to C.
> > register - support for defining hardware registers and accessors.
> >
> > Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
> <snip>
>
> > diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
> > index c859a8984bae..9c492fa10967 100644
> > --- a/rust/kernel/lib.rs
> > +++ b/rust/kernel/lib.rs
> > @@ -64,6 +64,7 @@
> > #[cfg(CONFIG_AUXILIARY_BUS)]
> > pub mod auxiliary;
> > pub mod bits;
> > +pub mod bitstruct;
> > #[cfg(CONFIG_BLOCK)]
> > pub mod block;
> > pub mod bug;
> > @@ -112,6 +113,7 @@
> > pub mod prelude;
> > pub mod print;
> > pub mod rbtree;
> > +pub mod register;
>
> I remember a discussion with Danilo where he mentioned the register
> macro should end up being in `kernel::io::register`.

I talked with Danilo, and I moved it to io for next revision.

> Also wondering whether `bitstruct` should not be in the
> appropriately-named `bits` module standing right above it. :)

I think now that I renamed it to bitfield, I'll move it to bits. That does
make a lot of sense.

thanks,

- Joel