diff --git a/devices/src/legacy/gpio_pl061.rs b/devices/src/legacy/gpio_pl061.rs index 23ebc7795..8aba26296 100644 --- a/devices/src/legacy/gpio_pl061.rs +++ b/devices/src/legacy/gpio_pl061.rs @@ -255,16 +255,15 @@ impl Gpio { impl BusDevice for Gpio { fn read(&mut self, _base: u64, offset: u64, data: &mut [u8]) { - let value; let mut read_ok = true; - if (GPIO_ID_LOW..GPIO_ID_HIGH).contains(&offset) { + let value = if (GPIO_ID_LOW..GPIO_ID_HIGH).contains(&offset) { let index = ((offset - GPIO_ID_LOW) >> 2) as usize; - value = u32::from(GPIO_ID[index]); + u32::from(GPIO_ID[index]) } else if offset < OFS_DATA { - value = self.data & ((offset >> 2) as u32); + self.data & ((offset >> 2) as u32) } else { - value = match offset { + match offset { GPIODIR => self.dir, GPIOIS => self.isense, GPIOIBE => self.ibe, @@ -277,8 +276,8 @@ impl BusDevice for Gpio { read_ok = false; 0 } - }; - } + } + }; if read_ok && data.len() <= 4 { write_le_u32(data, value);