spi: run rustfmt

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This commit is contained in:
Manos Pitsidianakis 2025-07-08 11:16:26 +03:00 committed by Stefano Garzarella
parent 81f1b8d59a
commit eb6acb3669
4 changed files with 26 additions and 20 deletions

View File

@ -39,7 +39,8 @@ pub struct SpiIocTransfer {
}
/// Linux SPI definitions
/// IOCTL commands, refer Linux's Documentation/spi/spidev.rst for further details.
/// IOCTL commands, refer Linux's Documentation/spi/spidev.rst for further
/// details.
const _IOC_SIZEBITS: u32 = 14;
const _IOC_SIZESHIFT: u32 = 16;
const SPI_IOC_MESSAGE_BASE: u32 = 0x40006b00;

View File

@ -22,12 +22,11 @@ use std::{
use clap::Parser;
use log::error;
use spi::{PhysDevice, SpiController, SpiDevice};
use thiserror::Error as ThisError;
use vhost_user_backend::VhostUserDaemon;
use vm_memory::{GuestMemoryAtomic, GuestMemoryMmap};
use spi::{PhysDevice, SpiController, SpiDevice};
use vhu_spi::VhostUserSpiBackend;
use vm_memory::{GuestMemoryAtomic, GuestMemoryMmap};
type Result<T> = std::result::Result<T, Error>;
@ -49,7 +48,8 @@ enum Error {
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct SpiArgs {
/// Location of vhost-user Unix domain socket. This is suffixed by 0,1,2..socket_count-1.
/// Location of vhost-user Unix domain socket. This is suffixed by
/// 0,1,2..socket_count-1.
#[clap(short, long)]
socket_path: PathBuf,
@ -176,9 +176,10 @@ fn main() {
#[cfg(test)]
pub(crate) mod tests {
use assert_matches::assert_matches;
use std::path::Path;
use assert_matches::assert_matches;
use super::*;
use crate::spi::tests::DummyDevice;

View File

@ -13,8 +13,10 @@ use std::{
};
use thiserror::Error as ThisError;
use vmm_sys_util::errno::Error as IoError;
use vmm_sys_util::ioctl::{ioctl_with_mut_ptr, ioctl_with_mut_ref, ioctl_with_ref};
use vmm_sys_util::{
errno::Error as IoError,
ioctl::{ioctl_with_mut_ptr, ioctl_with_mut_ref, ioctl_with_ref},
};
use crate::{linux_spi::*, vhu_spi::VirtioSpiConfig, virtio_spi::*};
@ -676,10 +678,12 @@ impl<D: SpiDevice> SpiController<D> {
#[cfg(test)]
pub(crate) mod tests {
use super::*;
use std::path::PathBuf;
use vmm_sys_util::tempfile::TempFile;
use super::*;
// Update read-buffer of each write-buffer with index + 1 value.
pub fn update_rdwr_buf(buf: u64, len: u32) {
let buf_ptr = buf as *mut u8;

View File

@ -17,17 +17,18 @@ use log::warn;
use thiserror::Error as ThisError;
use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures};
use vhost_user_backend::{VhostUserBackendMut, VringRwLock, VringT};
use virtio_bindings::bindings::virtio_config::{VIRTIO_F_NOTIFY_ON_EMPTY, VIRTIO_F_VERSION_1};
use virtio_bindings::bindings::virtio_ring::{
VIRTIO_RING_F_EVENT_IDX, VIRTIO_RING_F_INDIRECT_DESC,
use virtio_bindings::bindings::{
virtio_config::{VIRTIO_F_NOTIFY_ON_EMPTY, VIRTIO_F_VERSION_1},
virtio_ring::{VIRTIO_RING_F_EVENT_IDX, VIRTIO_RING_F_INDIRECT_DESC},
};
use virtio_queue::DescriptorChain;
use virtio_queue::QueueOwnedT;
use virtio_queue::{DescriptorChain, QueueOwnedT};
use vm_memory::{
ByteValued, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryLoadGuard, GuestMemoryMmap, Le32,
};
use vmm_sys_util::epoll::EventSet;
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};
use vmm_sys_util::{
epoll::EventSet,
eventfd::{EventFd, EFD_NONBLOCK},
};
use crate::spi::*;
@ -488,8 +489,8 @@ impl<D: 'static + SpiDevice + Sync + Send> VhostUserBackendMut for VhostUserSpiB
#[cfg(test)]
mod tests {
use std::path::PathBuf;
use std::slice::from_raw_parts;
use std::{path::PathBuf, slice::from_raw_parts};
use virtio_bindings::bindings::virtio_ring::{VRING_DESC_F_NEXT, VRING_DESC_F_WRITE};
use virtio_queue::{
desc::{split::Descriptor as SplitDescriptor, RawDescriptor},
@ -497,8 +498,7 @@ mod tests {
};
use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic, GuestMemoryMmap};
use super::Error;
use super::*;
use super::{Error, *};
use crate::spi::tests::{verify_rdwr_buf, DummyDevice};
// Prepares descriptor chains