Skip to content

Commit fdfe94b

Browse files
authored
Merge pull request #21 from mripard/fixes
Various Fixes
2 parents e689436 + d3287b3 commit fdfe94b

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ repository = "https://github.com/mripard/dma-heap/"
1313
[dependencies]
1414
log = "0.4.27"
1515
rustix = { version = "1.0.7", features = ["fs"] }
16-
strum_macros = "0.27.1"
1716

1817
[features]
1918
nightly = []

src/ioctl.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,9 @@ fn dma_heap_alloc_ioctl(fd: BorrowedFd<'_>, data: &mut dma_heap_allocation_data)
3737
}
3838

3939
pub(crate) fn dma_heap_alloc(fd: BorrowedFd<'_>, len: usize) -> io::Result<OwnedFd> {
40-
let mut fd_flags = OFlags::empty();
41-
42-
fd_flags.insert(OFlags::CLOEXEC);
43-
fd_flags.insert(OFlags::RDWR);
44-
4540
let mut data = dma_heap_allocation_data {
4641
len: len as u64,
47-
fd_flags: fd_flags.bits(),
42+
fd_flags: OFlags::union(OFlags::CLOEXEC, OFlags::RDWR).bits(),
4843
..dma_heap_allocation_data::default()
4944
};
5045

src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#![doc = include_str!("../README.md")]
1919
#![allow(unsafe_code)]
2020

21+
use core::fmt;
2122
use std::{
2223
fs::File,
2324
io,
@@ -28,10 +29,9 @@ use std::{
2829
mod ioctl;
2930
use ioctl::dma_heap_alloc;
3031
use log::debug;
31-
use strum_macros::Display;
3232

3333
/// Various Types of DMA-Buf Heap
34-
#[derive(Clone, Debug, Display)]
34+
#[derive(Clone, Debug)]
3535
pub enum HeapKind {
3636
/// A Heap backed by the Contiguous Memory Allocator in the Linux kernel, returning physically
3737
/// contiguous, cached, buffers
@@ -45,6 +45,16 @@ pub enum HeapKind {
4545
Custom(PathBuf),
4646
}
4747

48+
impl fmt::Display for HeapKind {
49+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50+
match self {
51+
HeapKind::Cma => f.write_str("CMA"),
52+
HeapKind::System => f.write_str("System"),
53+
HeapKind::Custom(p) => f.write_fmt(format_args!("Custom Heap ({})", p.display())),
54+
}
55+
}
56+
}
57+
4858
/// Our DMA-Buf Heap
4959
#[derive(Debug)]
5060
pub struct Heap {

0 commit comments

Comments
 (0)