Re: [PATCH v4 1/6] rust: bitmap: add MAX_LEN and NO_ALLOC_MAX_LEN constants
From: Alice Ryhl
Date: Mon Nov 10 2025 - 09:20:29 EST
On Mon, Nov 10, 2025 at 08:59:36AM -0500, Tamir Duberstein wrote:
> On Mon, Nov 10, 2025 at 8:06 AM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
> >
> > To avoid hard-coding these values in drivers, define constants for them
> > that drivers can reference.
> >
> > Acked-by: Danilo Krummrich <dakr@xxxxxxxxxx>
> > Reviewed-by: Burak Emir <bqe@xxxxxxxxxx>
> > Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> > ---
> > rust/kernel/bitmap.rs | 16 +++++++++++-----
> > 1 file changed, 11 insertions(+), 5 deletions(-)
> >
> > diff --git a/rust/kernel/bitmap.rs b/rust/kernel/bitmap.rs
> > index aa8fc7bf06fc99865ae755d8694e4bec3dc8e7f0..15fa23b45054b9272415fcc000e3e3b52c74d7c1 100644
> > --- a/rust/kernel/bitmap.rs
> > +++ b/rust/kernel/bitmap.rs
> > @@ -149,14 +149,14 @@ macro_rules! bitmap_assert_return {
> > ///
> > /// # Invariants
> > ///
> > -/// * `nbits` is `<= i32::MAX` and never changes.
> > +/// * `nbits` is `<= MAX_LEN`.
> > /// * if `nbits <= bindings::BITS_PER_LONG`, then `repr` is a `usize`.
>
> Should this and other references to bindings::BITS_PER_LONG be
> `NO_ALLOC_MAX_LEN` instead?
Ah yeah it probably makes sense to update this in a bunch of places.
Alice