Re: [PATCH v2 2/5] rust: dma: add DMA addressing capabilities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Danilo,

> +    #[inline]
> +    pub const fn new(n: usize) -> Result<Self> {
> +        Ok(Self(match n {
> +            0 => 0,
> +            1..=64 => u64::MAX >> (64 - n),
> +            _ => return Err(EINVAL),
> +        }))
> +    }
> +

Isn’t this equivalent to genmask_u64(0..=n) ? See [0].

You should also get a compile-time failure if n is out of bounds by default using
genmask.

— Daniel

[0]: https://lore.kernel.org/rust-for-linux/20250714-topics-tyr-genmask2-v9-1-9e6422cbadb6@xxxxxxxxxxxxx/#r




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux