aarch64: Address Rust 1.51.0 clippy issue (upper_case_acroynms)

error: name `GPIOInterruptDisabled` contains a capitalized acronym

Error:   --> devices/src/legacy/gpio_pl061.rs:46:5
   |
46 |     GPIOInterruptDisabled,
   |     ^^^^^^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GpioInterruptDisabled`
   |
   = note: `-D clippy::upper-case-acronyms` implied by `-D warnings`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2021-03-25 17:01:21 +00:00
parent 3c6dfd7709
commit 40da6210f4
12 changed files with 202 additions and 202 deletions

View File

@@ -43,20 +43,20 @@ const N_GPIOS: u32 = 8;
#[derive(Debug)]
pub enum Error {
BadWriteOffset(u64),
GPIOInterruptDisabled,
GPIOInterruptFailure(io::Error),
GPIOTriggerKeyFailure(u32),
GpioInterruptDisabled,
GpioInterruptFailure(io::Error),
GpioTriggerKeyFailure(u32),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Error::BadWriteOffset(offset) => write!(f, "Bad Write Offset: {}", offset),
Error::GPIOInterruptDisabled => write!(f, "GPIO interrupt disabled by guest driver.",),
Error::GPIOInterruptFailure(ref e) => {
Error::GpioInterruptDisabled => write!(f, "GPIO interrupt disabled by guest driver.",),
Error::GpioInterruptFailure(ref e) => {
write!(f, "Could not trigger GPIO interrupt: {}.", e)
}
Error::GPIOTriggerKeyFailure(key) => {
Error::GpioTriggerKeyFailure(key) => {
write!(f, "Invalid GPIO Input key triggerd: {}.", key)
}
}
@@ -66,7 +66,7 @@ impl fmt::Display for Error {
type Result<T> = result::Result<T, Error>;
/// A GPIO device following the PL061 specification.
pub struct GPIO {
pub struct Gpio {
id: String,
// Data Register
data: u32,
@@ -90,7 +90,7 @@ pub struct GPIO {
}
#[derive(Serialize, Deserialize)]
pub struct GPIOState {
pub struct GpioState {
data: u32,
old_in_data: u32,
dir: u32,
@@ -102,10 +102,10 @@ pub struct GPIOState {
afsel: u32,
}
impl GPIO {
impl Gpio {
/// Constructs an PL061 GPIO device.
pub fn new(id: String, interrupt: Arc<Box<dyn InterruptSourceGroup>>) -> GPIO {
GPIO {
pub fn new(id: String, interrupt: Arc<Box<dyn InterruptSourceGroup>>) -> Self {
Self {
id,
data: 0,
old_in_data: 0,
@@ -120,8 +120,8 @@ impl GPIO {
}
}
fn state(&self) -> GPIOState {
GPIOState {
fn state(&self) -> GpioState {
GpioState {
data: self.data,
old_in_data: self.old_in_data,
dir: self.dir,
@@ -134,7 +134,7 @@ impl GPIO {
}
}
fn set_state(&mut self, state: &GPIOState) {
fn set_state(&mut self, state: &GpioState) {
self.data = state.data;
self.old_in_data = state.old_in_data;
self.dir = state.dir;
@@ -233,12 +233,12 @@ impl GPIO {
self.pl061_internal_update();
match self.trigger_gpio_interrupt() {
Ok(_) | Err(Error::GPIOInterruptDisabled) => return Ok(()),
Ok(_) | Err(Error::GpioInterruptDisabled) => return Ok(()),
Err(e) => return Err(e),
}
}
Err(Error::GPIOTriggerKeyFailure(key))
Err(Error::GpioTriggerKeyFailure(key))
}
fn trigger_gpio_interrupt(&self) -> Result<()> {
@@ -246,16 +246,16 @@ impl GPIO {
// trigger their individual interrupts and then the combined GPIOINTR line.
if (self.istate & self.im) == 0 {
warn!("Failed to trigger GPIO input interrupt (disabled by guest OS)");
return Err(Error::GPIOInterruptDisabled);
return Err(Error::GpioInterruptDisabled);
}
self.interrupt
.trigger(0)
.map_err(Error::GPIOInterruptFailure)?;
.map_err(Error::GpioInterruptFailure)?;
Ok(())
}
}
impl BusDevice for GPIO {
impl BusDevice for Gpio {
fn read(&mut self, _base: u64, offset: u64, data: &mut [u8]) {
let value;
let mut read_ok = true;
@@ -311,7 +311,7 @@ impl BusDevice for GPIO {
}
}
impl Snapshottable for GPIO {
impl Snapshottable for Gpio {
fn id(&self) -> String {
self.id.clone()
}
@@ -352,9 +352,9 @@ impl Snapshottable for GPIO {
}
}
impl Pausable for GPIO {}
impl Transportable for GPIO {}
impl Migratable for GPIO {}
impl Pausable for Gpio {}
impl Transportable for Gpio {}
impl Migratable for Gpio {}
#[cfg(test)]
mod tests {
@@ -398,7 +398,7 @@ mod tests {
#[test]
fn test_gpio_read_write_and_event() {
let intr_evt = EventFd::new(libc::EFD_NONBLOCK).unwrap();
let mut gpio = GPIO::new(
let mut gpio = Gpio::new(
String::from(GPIO_NAME),
Arc::new(Box::new(TestInterrupt::new(intr_evt.try_clone().unwrap()))),
);

View File

@@ -26,10 +26,10 @@ pub use self::i8042::I8042Device;
pub use self::serial::Serial;
#[cfg(target_arch = "aarch64")]
pub use self::gpio_pl061::Error as GPIODeviceError;
pub use self::gpio_pl061::Error as GpioDeviceError;
#[cfg(target_arch = "aarch64")]
pub use self::gpio_pl061::GPIO;
pub use self::gpio_pl061::Gpio;
#[cfg(target_arch = "aarch64")]
pub use self::rtc_pl031::RTC;
pub use self::rtc_pl031::Rtc;
#[cfg(target_arch = "aarch64")]
pub use self::uart_pl011::PL011;
pub use self::uart_pl011::Pl011;

View File

@@ -215,7 +215,7 @@ pub fn seconds_to_nanoseconds(value: i64) -> Option<i64> {
}
/// A RTC device following the PL031 specification..
pub struct RTC {
pub struct Rtc {
previous_now: Instant,
tick_offset: i64,
// This is used for implementing the RTC alarm. However, in Firecracker we do not need it.
@@ -227,10 +227,10 @@ pub struct RTC {
interrupt: Arc<Box<dyn InterruptSourceGroup>>,
}
impl RTC {
impl Rtc {
/// Constructs an AMBA PL031 RTC device.
pub fn new(interrupt: Arc<Box<dyn InterruptSourceGroup>>) -> RTC {
RTC {
pub fn new(interrupt: Arc<Box<dyn InterruptSourceGroup>>) -> Self {
Self {
// This is used only for duration measuring purposes.
previous_now: Instant::now(),
tick_offset: get_time(ClockType::Real) as i64,
@@ -289,7 +289,7 @@ impl RTC {
}
}
impl BusDevice for RTC {
impl BusDevice for Rtc {
fn read(&mut self, _base: u64, offset: u64, data: &mut [u8]) {
let v;
let mut read_ok = true;
@@ -450,7 +450,7 @@ mod tests {
fn test_rtc_read_write_and_event() {
let intr_evt = EventFd::new(libc::EFD_NONBLOCK).unwrap();
let mut rtc = RTC::new(Arc::new(Box::new(TestInterrupt::new(
let mut rtc = Rtc::new(Arc::new(Box::new(TestInterrupt::new(
intr_evt.try_clone().unwrap(),
))));
let mut data = [0; 4];

View File

@@ -49,7 +49,7 @@ const AMBA_ID_HIGH: u64 = 0x401;
#[derive(Debug)]
pub enum Error {
BadWriteOffset(u64),
DMANotImplemented,
DmaNotImplemented,
InterruptFailure(io::Error),
WriteAllFailure(io::Error),
FlushFailure(io::Error),
@@ -59,7 +59,7 @@ impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Error::BadWriteOffset(offset) => write!(f, "pl011_write: Bad Write Offset: {}", offset),
Error::DMANotImplemented => write!(f, "pl011: DMA not implemented."),
Error::DmaNotImplemented => write!(f, "pl011: DMA not implemented."),
Error::InterruptFailure(e) => write!(f, "Failed to trigger interrupt: {}", e),
Error::WriteAllFailure(e) => write!(f, "Failed to write: {}", e),
Error::FlushFailure(e) => write!(f, "Failed to flush: {}", e),
@@ -70,7 +70,7 @@ impl fmt::Display for Error {
type Result<T> = result::Result<T, Error>;
/// A PL011 device following the PL011 specification.
pub struct PL011 {
pub struct Pl011 {
id: String,
flags: u32,
lcr: u32,
@@ -91,7 +91,7 @@ pub struct PL011 {
}
#[derive(Serialize, Deserialize)]
pub struct PL011State {
pub struct Pl011State {
flags: u32,
lcr: u32,
rsr: u32,
@@ -108,14 +108,14 @@ pub struct PL011State {
read_trigger: u32,
}
impl PL011 {
impl Pl011 {
/// Constructs an AMBA PL011 UART device.
pub fn new(
id: String,
irq: Arc<Box<dyn InterruptSourceGroup>>,
out: Option<Box<dyn io::Write + Send>>,
) -> PL011 {
PL011 {
) -> Self {
Self {
id,
flags: 0x90u32,
lcr: 0u32,
@@ -136,8 +136,8 @@ impl PL011 {
}
}
fn state(&self) -> PL011State {
PL011State {
fn state(&self) -> Pl011State {
Pl011State {
flags: self.flags,
lcr: self.lcr,
rsr: self.rsr,
@@ -155,7 +155,7 @@ impl PL011 {
}
}
fn set_state(&mut self, state: &PL011State) {
fn set_state(&mut self, state: &Pl011State) {
self.flags = state.flags;
self.lcr = state.lcr;
self.rsr = state.rsr;
@@ -264,7 +264,7 @@ impl PL011 {
UARTDMACR => {
self.dmacr = val;
if (val & 3) != 0 {
return Err(Error::DMANotImplemented);
return Err(Error::DmaNotImplemented);
}
}
off => {
@@ -279,7 +279,7 @@ impl PL011 {
}
}
impl BusDevice for PL011 {
impl BusDevice for Pl011 {
fn read(&mut self, _base: u64, offset: u64, data: &mut [u8]) {
let v;
let mut read_ok = true;
@@ -355,7 +355,7 @@ impl BusDevice for PL011 {
}
}
impl Snapshottable for PL011 {
impl Snapshottable for Pl011 {
fn id(&self) -> String {
self.id.clone()
}
@@ -396,9 +396,9 @@ impl Snapshottable for PL011 {
}
}
impl Pausable for PL011 {}
impl Transportable for PL011 {}
impl Migratable for PL011 {}
impl Pausable for Pl011 {}
impl Transportable for Pl011 {}
impl Migratable for Pl011 {}
#[cfg(test)]
mod tests {
@@ -462,7 +462,7 @@ mod tests {
fn pl011_output() {
let intr_evt = EventFd::new(0).unwrap();
let pl011_out = SharedBuffer::new();
let mut pl011 = PL011::new(
let mut pl011 = Pl011::new(
String::from(SERIAL_NAME),
Arc::new(Box::new(TestInterrupt::new(intr_evt.try_clone().unwrap()))),
Some(Box::new(pl011_out.clone())),
@@ -482,7 +482,7 @@ mod tests {
fn pl011_input() {
let intr_evt = EventFd::new(0).unwrap();
let pl011_out = SharedBuffer::new();
let mut pl011 = PL011::new(
let mut pl011 = Pl011::new(
String::from(SERIAL_NAME),
Arc::new(Box::new(TestInterrupt::new(intr_evt.try_clone().unwrap()))),
Some(Box::new(pl011_out)),