diff --git a/gpio/src/backend.rs b/gpio/src/backend.rs index 7734dbd..1ade0d6 100644 --- a/gpio/src/backend.rs +++ b/gpio/src/backend.rs @@ -23,7 +23,7 @@ pub(crate) type Result = std::result::Result; #[derive(Debug, Eq, PartialEq, ThisError)] /// Errors related to low level GPIO helpers -pub enum Error { +pub(crate) enum Error { #[error("Invalid socket count: {0}")] SocketCountInvalid(usize), #[error("Socket count ({0}) doesn't match device count {1}")] diff --git a/i2c/src/i2c.rs b/i2c/src/i2c.rs index 1a3529f..a2f88e4 100644 --- a/i2c/src/i2c.rs +++ b/i2c/src/i2c.rs @@ -27,7 +27,7 @@ type Result = std::result::Result; #[derive(Copy, Clone, Debug, PartialEq, ThisError)] /// Errors related to low level i2c helpers -pub enum Error { +pub(crate) enum Error { #[error("Incorrect message length for {0} operation: {1}")] MessageLengthInvalid(&'static str, usize), #[error("Invalid SMBUS command: {0}")] @@ -74,7 +74,7 @@ const I2C_FUNC_SMBUS_ALL: u64 = I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA; /// I2C protocol definitions -pub const I2C_M_RD: u16 = 0x0001; // read data, from slave to master +pub(crate) const I2C_M_RD: u16 = 0x0001; // read data, from slave to master /// Copied (partially) from Linux's include/uapi/linux/i2c.h /// @@ -115,7 +115,7 @@ struct I2cMsg { /// This is the structure as used in the I2C_RDWR ioctl call #[repr(C)] -pub struct I2cRdwrIoctlData { +pub(crate) struct I2cRdwrIoctlData { msgs: *mut I2cMsg, nmsgs: u32, } @@ -157,14 +157,14 @@ impl I2cSmbusData { /// This is the structure as used in the I2C_SMBUS ioctl call #[repr(C)] -pub struct I2cSmbusIoctlData { +pub(crate) struct I2cSmbusIoctlData { read_write: u8, command: u8, size: u32, data: *mut I2cSmbusData, } -pub struct SmbusMsg { +pub(crate) struct SmbusMsg { read_write: u8, command: u8, size: u32, @@ -284,7 +284,7 @@ impl SmbusMsg { } /// I2C definitions -pub struct I2cReq { +pub(crate) struct I2cReq { pub addr: u16, pub flags: u16, pub len: u16, @@ -297,7 +297,7 @@ pub struct I2cReq { /// be used outside of this crate. The purpose of this trait is to provide a /// mock implementation for the I2C driver so that we can test the I2C /// functionality without the need of a physical device. -pub trait I2cDevice { +pub(crate) trait I2cDevice { // Open the device specified by the adapter number. fn open(device_path: &str, adapter_no: u32) -> Result where @@ -322,7 +322,7 @@ pub trait I2cDevice { /// A physical I2C device. This structure can only be initialized on hosts /// where `/dev/i2c-XX` is available. #[derive(Debug)] -pub struct PhysDevice { +pub(crate) struct PhysDevice { file: File, adapter_no: u32, } @@ -425,7 +425,7 @@ impl I2cDevice for PhysDevice { } #[derive(Debug)] -pub struct I2cAdapter { +pub(crate) struct I2cAdapter { device: D, adapter_no: u32, smbus: bool, @@ -507,7 +507,7 @@ impl I2cAdapter { /// I2C map and helpers pub(crate) const MAX_I2C_VDEV: usize = 1 << 7; -pub struct I2cMap { +pub(crate) struct I2cMap { adapters: Vec>, device_map: HashMap, } @@ -569,7 +569,7 @@ impl I2cMap { } #[cfg(test)] -pub mod tests { +pub(crate) mod tests { use super::*; use vmm_sys_util::tempfile::TempFile; diff --git a/i2c/src/main.rs b/i2c/src/main.rs index 0dee159..1bc391e 100644 --- a/i2c/src/main.rs +++ b/i2c/src/main.rs @@ -26,7 +26,7 @@ type Result = std::result::Result; #[derive(Debug, PartialEq, ThisError)] /// Errors related to low level i2c helpers -pub enum Error { +pub(crate) enum Error { #[error("Invalid socket count: {0}")] SocketCountInvalid(usize), #[error("Invalid device list")] diff --git a/i2c/src/vhu_i2c.rs b/i2c/src/vhu_i2c.rs index 41c4152..2d0a472 100644 --- a/i2c/src/vhu_i2c.rs +++ b/i2c/src/vhu_i2c.rs @@ -38,7 +38,7 @@ type VhostUserBackendResult = std::result::Result; #[derive(Copy, Clone, Debug, Eq, PartialEq, ThisError)] /// Errors related to vhost-device-i2c daemon. -pub enum Error { +pub(crate) enum Error { #[error("Failed to handle event, didn't match EPOLLIN")] HandleEventNotEpollIn, #[error("Failed to handle unknown event")] @@ -94,7 +94,7 @@ struct VirtioI2cInHdr { } unsafe impl ByteValued for VirtioI2cInHdr {} -pub struct VhostUserI2cBackend { +pub(crate) struct VhostUserI2cBackend { i2c_map: Arc>, event_idx: bool, pub exit_event: EventFd, diff --git a/rng/src/main.rs b/rng/src/main.rs index 20851ae..ea4f457 100644 --- a/rng/src/main.rs +++ b/rng/src/main.rs @@ -26,7 +26,7 @@ type Result = std::result::Result; #[derive(Debug, Eq, PartialEq, ThisError)] /// Errors related to vhost-device-rng daemon. -pub enum Error { +pub(crate) enum Error { #[error("RNG source file doesn't exists or can't be accessed")] AccessRngSourceFile, #[error("Period is too big: {0}")] @@ -62,7 +62,7 @@ struct RngArgs { } #[derive(Clone, Debug, Eq, PartialEq)] -pub struct VuRngConfig { +pub(crate) struct VuRngConfig { pub period_ms: u128, pub max_bytes: usize, pub count: u32, @@ -98,7 +98,7 @@ impl TryFrom for VuRngConfig { } } -pub fn start_backend(config: VuRngConfig) -> Result<()> { +pub(crate) fn start_backend(config: VuRngConfig) -> Result<()> { let mut handles = Vec::new(); let file = File::open(&config.rng_source).map_err(|_| Error::AccessRngSourceFile)?; let random_file = Arc::new(Mutex::new(file)); diff --git a/rng/src/vhu_rng.rs b/rng/src/vhu_rng.rs index f32914f..31606c4 100644 --- a/rng/src/vhu_rng.rs +++ b/rng/src/vhu_rng.rs @@ -34,7 +34,7 @@ type RngDescriptorChain = DescriptorChain for io::Error { } #[derive(Clone, Debug, Eq, PartialEq)] -pub struct VuRngTimerConfig { +pub(crate) struct VuRngTimerConfig { period_ms: u128, period_start: Instant, max_bytes: usize, @@ -84,7 +84,7 @@ impl VuRngTimerConfig { } } -pub struct VuRngBackend { +pub(crate) struct VuRngBackend { event_idx: bool, timer: VuRngTimerConfig, rng_source: Arc>,