Re: [PATCH 1/4] rust: dma: implement DataDirection

From: Alice Ryhl
Date: Mon Aug 18 2025 - 14:49:41 EST


On Mon, Aug 18, 2025 at 7:23 PM Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> On Mon Aug 18, 2025 at 4:00 PM CEST, Alice Ryhl wrote:
> > In general, I think we want some sort of helper function to cast
> > between arbitrary integer types in const-evaluation that panics if the
> > cast is out of bounds. Both here and many other places.
>
> What exactly do you have in mind?

pub enum DataDirection {
/// The DMA mapping is for bidirectional data transfer.
///
/// This is used when the buffer can be both read from and
written to by the device.
/// The cache for the corresponding memory region is both
flushed and invalidated.
Bidirectional =
const_cast(bindings::dma_data_direction_DMA_BIDIRECTIONAL),

with no warnings and build-failure if out-of-bounds.

Alice