On Tue Feb 10, 2026 at 3:45 AM CET, John Hubbard wrote:
> diff --git a/drivers/gpu/nova-core/num.rs b/drivers/gpu/nova-core/num.rs
> index c952a834e662..f068722c5bdf 100644
> --- a/drivers/gpu/nova-core/num.rs
> +++ b/drivers/gpu/nova-core/num.rs
> @@ -215,3 +215,13 @@ pub(crate) const fn [<$from _into_ $into>]<const N: 
> $from>() -> $into {
>  impl_const_into!(u64 => { u8, u16, u32 });
>  impl_const_into!(u32 => { u8, u16 });
>  impl_const_into!(u16 => { u8 });
> +
> +/// Aligns `value` up to `ALIGN` at compile time.
> +///
> +/// This is the const-compatible equivalent of 
> [`kernel::ptr::Alignable::align_up`].
> +/// `ALIGN` must be a power of two (enforced at compile time).
> +#[inline(always)]
> +pub(crate) const fn const_align_up<const ALIGN: usize>(value: usize) -> 
> usize {

We should probably just add this as a function to Alignable.

> +    build_assert!(ALIGN.is_power_of_two());

ALIGN is a const generic, hence this should be:

        const { core::assert!(ALIGN.is_power_of_two(), "ALIGN must be a power 
of two") };

> +    (value + (ALIGN - 1)) & !(ALIGN - 1)
> +}

Reply via email to