Re: [PATCH v3 1/2] rust: sizes: add DeviceSize trait for device address space constants
From: Miguel Ojeda
Date: Wed Apr 01 2026 - 06:25:20 EST
On Wed, Apr 1, 2026 at 12:43 AM John Hubbard <jhubbard@xxxxxxxxxx> wrote:
>
> +//! // usize constant (CPU-side)
Some nits below -- possibly for apply time.
Markdown and period:
//! // `usize` constant (CPU-side).
> +//! let num_pages_in_1m: usize = SZ_1M / kernel::page::PAGE_SIZE;
Perhaps import `PAGE_SIZE` since we are doing imports above anyway?
> +//! // Device-side constant via the trait
Period at the end.
> +//! let heap_size: u64 = 14 * u64::SZ_1M;
> +//! let small: u32 = u32::SZ_4K;
I guess the resulting types here are to make it clearer; or do we
expect people to write the sizes for this? i.e. since part of the
advantage of using the constants is that you get them already typed, I
wonder if we should write the code as we would normally expect it to
be written.
Also, I always consider in examples whether to add `assert_eq!`s, but
I am ambivalent for this case.
> + /// 0x0000_0400
> + SZ_1K,
This is consistent with the other constants, but I wonder if there was
a reason to not do something like:
/// `0x0000_0400`.
Anyway, all these is minor or can be fixed on apply.
These constants are meant to be useful soon, so we could do the same
as with the other patch, i.e. I could pick it already it depending on
the rest of the discussion (especially if we confirm that the user
patch is what we want).
Thanks!
Cheers,
Miguel