impl MyStruct { fn new(h: u32, b: u32) -> Self { Self { h, b }
}
} // SAFETY: All bit patterns are acceptable values for `MyStruct`. unsafeimpl kernel::transmute::AsBytes for MyStruct {} // SAFETY: Instances of `MyStruct` have no uninitialized portions. unsafeimpl kernel::transmute::FromBytes for MyStruct {}
// SAFETY: There are no concurrent calls to DMA allocation and mapping primitives. unsafe { pdev.dma_set_mask_and_coherent(mask)? };
let ca: CoherentAllocation<MyStruct> =
CoherentAllocation::alloc_coherent(pdev.as_ref(), TEST_VALUES.len(), GFP_KERNEL)?;
for (i, value) in TEST_VALUES.into_iter().enumerate() {
kernel::dma_write!(ca[i] = MyStruct::new(value.0, value.1))?;
}
let drvdata = KBox::new( Self {
pdev: pdev.into(),
ca,
},
GFP_KERNEL,
)?;
Ok(drvdata.into())
}
}
impl Drop for DmaSampleDriver { fn drop(&mutself) {
dev_info!(self.pdev.as_ref(), "Unload DMA test driver.\n");
for (i, value) in TEST_VALUES.into_iter().enumerate() { let val0 = kernel::dma_read!(self.ca[i].h); let val1 = kernel::dma_read!(self.ca[i].b);
assert!(val0.is_ok());
assert!(val1.is_ok());
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet am 2026-06-21)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.