Re: [PATCH v9] rust: kernel: add support for bits/genmask macros

From: Miguel Ojeda
Date: Sat Jul 19 2025 - 18:17:41 EST


On Tue, Jul 15, 2025 at 1:30 AM Daniel Almeida
<daniel.almeida@xxxxxxxxxxxxx> wrote:
>
> In light of bindgen being unable to generate bindings for macros, and
> owing to the widespread use of these macros in drivers, manually define
> the bit and genmask C macros in Rust.
>
> The *_checked version of the functions provide runtime checking while
> the const version performs compile-time assertions on the arguments via
> the build_assert!() macro.
>
> Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> Reviewed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
> Signed-off-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>

Applied to `rust-next` -- thanks everyone!

[ `expect`ed Clippy warning in doctests, hid single `use`, grouped
examples. Reworded title. - Miguel ]

Cheers,
Miguel