Merge branch 'rustfmt_more_things' into 'master'

Rustfmt a couple more crates

See merge request redox-os/drivers!189
This commit is contained in:
Jeremy Soller
2024-07-21 12:59:28 +00:00
5 changed files with 25 additions and 15 deletions
+7 -3
View File
@@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut};
use std::ptr;
use libredox::call::MmapArgs;
use libredox::{flag, error::Result, Fd};
use libredox::{error::Result, flag, Fd};
use syscall::PAGE_SIZE;
use crate::MemoryType;
@@ -34,7 +34,7 @@ fn alloc_and_map(length: usize) -> Result<(usize, *mut ())> {
let fd = phys_contiguous_fd()?;
let virt = libredox::call::mmap(MmapArgs {
fd: fd.raw(),
offset: 0, // ignored
offset: 0, // ignored
addr: core::ptr::null_mut(), // ignored
length,
flags: flag::MAP_PRIVATE,
@@ -42,7 +42,11 @@ fn alloc_and_map(length: usize) -> Result<(usize, *mut ())> {
})?;
let phys = syscall::virttophys(virt as usize)?;
for i in 1..length.div_ceil(PAGE_SIZE) {
debug_assert_eq!(syscall::virttophys(virt as usize + i * PAGE_SIZE), Ok(phys + i * PAGE_SIZE), "NOT CONTIGUOUS");
debug_assert_eq!(
syscall::virttophys(virt as usize + i * PAGE_SIZE),
Ok(phys + i * PAGE_SIZE),
"NOT CONTIGUOUS"
);
}
Ok((phys, virt as *mut ()))
}
+1 -1
View File
@@ -1,8 +1,8 @@
#![feature(int_roundings)]
use libredox::call::MmapArgs;
use libredox::{Fd, error::*, errno::EINVAL};
use libredox::flag::{self, O_CLOEXEC, O_RDONLY, O_RDWR, O_WRONLY};
use libredox::{errno::EINVAL, error::*, Fd};
use syscall::PAGE_SIZE;
pub mod dma;
+11 -3
View File
@@ -35,7 +35,8 @@ impl Sgl {
offset: 0,
fd: !0,
addr: core::ptr::null_mut(),
})?.cast::<u8>();
})?
.cast::<u8>();
let mut this = Self {
virt,
@@ -51,7 +52,9 @@ impl Sgl {
let mut offset = 0;
while offset < unaligned_length.get() {
let chunk_length = (aligned_length - offset).min(MAX_ALLOC_SIZE).next_power_of_two();
let chunk_length = (aligned_length - offset)
.min(MAX_ALLOC_SIZE)
.next_power_of_two();
libredox::call::mmap(MmapArgs {
addr: virt.add(offset).cast(),
flags: MAP_PRIVATE | (MAP_FIXED.bits() as u32),
@@ -62,7 +65,12 @@ impl Sgl {
offset: 0,
})?;
let phys = syscall::virttophys(virt as usize + offset)?;
this.chunks.push(Chunk { offset, phys, length: (unaligned_length.get() - offset).min(chunk_length), virt: virt.add(offset) });
this.chunks.push(Chunk {
offset,
phys,
length: (unaligned_length.get() - offset).min(chunk_length),
virt: virt.add(offset),
});
offset += chunk_length;
}
+4 -1
View File
@@ -16,11 +16,14 @@ function fmt() {
done
}
fmt graphics/bgad \
fmt common \
graphics/bgad \
graphics/fbcond \
graphics/vesad \
graphics/virtio-gpud \
inputd \
net/driver-network \
net/virtio-netd \
pcid \
storage/driver-block \
virtio-core
+2 -7
View File
@@ -126,13 +126,8 @@ impl DiskWrapper {
}
}
};
let bytes_read = block_read(
self.offset,
blksize,
buf,
self.block_bytes,
read_block,
)?;
let bytes_read =
block_read(self.offset, blksize, buf, self.block_bytes, read_block)?;
self.offset += bytes_read as u64;
Ok(bytes_read)