Skip to content

Commit 7bd1710

Browse files
author
Danilo Krummrich
committed
rust: dma: require a bound device
Require the Bound device context to be able to create new dma::CoherentAllocation instances. DMA memory allocations are only valid to be created for bound devices. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Danilo Krummrich <[email protected]>
1 parent f720efd commit 7bd1710

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

rust/kernel/dma.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
use crate::{
88
bindings, build_assert,
9-
device::Device,
9+
device::{Bound, Device},
1010
error::code::*,
1111
error::Result,
1212
transmute::{AsBytes, FromBytes},
@@ -22,10 +22,10 @@ use crate::{
2222
/// # Examples
2323
///
2424
/// ```
25-
/// use kernel::device::Device;
25+
/// # use kernel::device::{Bound, Device};
2626
/// use kernel::dma::{attrs::*, CoherentAllocation};
2727
///
28-
/// # fn test(dev: &Device) -> Result {
28+
/// # fn test(dev: &Device<Bound>) -> Result {
2929
/// let attribs = DMA_ATTR_FORCE_CONTIGUOUS | DMA_ATTR_NO_WARN;
3030
/// let c: CoherentAllocation<u64> =
3131
/// CoherentAllocation::alloc_attrs(dev, 4, GFP_KERNEL, attribs)?;
@@ -143,16 +143,16 @@ impl<T: AsBytes + FromBytes> CoherentAllocation<T> {
143143
/// # Examples
144144
///
145145
/// ```
146-
/// use kernel::device::Device;
146+
/// # use kernel::device::{Bound, Device};
147147
/// use kernel::dma::{attrs::*, CoherentAllocation};
148148
///
149-
/// # fn test(dev: &Device) -> Result {
149+
/// # fn test(dev: &Device<Bound>) -> Result {
150150
/// let c: CoherentAllocation<u64> =
151151
/// CoherentAllocation::alloc_attrs(dev, 4, GFP_KERNEL, DMA_ATTR_NO_WARN)?;
152152
/// # Ok::<(), Error>(()) }
153153
/// ```
154154
pub fn alloc_attrs(
155-
dev: &Device,
155+
dev: &Device<Bound>,
156156
count: usize,
157157
gfp_flags: kernel::alloc::Flags,
158158
dma_attrs: Attrs,
@@ -194,7 +194,7 @@ impl<T: AsBytes + FromBytes> CoherentAllocation<T> {
194194
/// Performs the same functionality as [`CoherentAllocation::alloc_attrs`], except the
195195
/// `dma_attrs` is 0 by default.
196196
pub fn alloc_coherent(
197-
dev: &Device,
197+
dev: &Device<Bound>,
198198
count: usize,
199199
gfp_flags: kernel::alloc::Flags,
200200
) -> Result<CoherentAllocation<T>> {

0 commit comments

Comments
 (0)