rust: pl011: simplify handling of the FIFO enabled bit in LCR
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 4 Dec 2024 20:49:34 +0000 (21:49 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 19 Dec 2024 18:36:38 +0000 (19:36 +0100)
Use ==/!= instead of going through bool and xor.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/hw/char/pl011/src/device.rs
rust/hw/char/pl011/src/lib.rs

index 4d620b442edd68f13601c6a67dde1d11c0f0373d..18cc122951db20e10bdcaada8338cca324070919 100644 (file)
@@ -302,9 +302,7 @@ impl PL011State {
             Ok(LCR_H) => {
                 let new_val: registers::LineControl = value.into();
                 // Reset the FIFO state on FIFO enable or disable
-                if bool::from(self.line_control.fifos_enabled())
-                    ^ bool::from(new_val.fifos_enabled())
-                {
+                if self.line_control.fifos_enabled() != new_val.fifos_enabled() {
                     self.reset_rx_fifo();
                     self.reset_tx_fifo();
                 }
@@ -497,7 +495,7 @@ impl PL011State {
 
     #[inline]
     pub fn fifo_enabled(&self) -> bool {
-        matches!(self.line_control.fifos_enabled(), registers::Mode::FIFO)
+        self.line_control.fifos_enabled() == registers::Mode::FIFO
     }
 
     #[inline]
index 0747e130cae4bf13a7c2aa0f0b592fa177d467bd..69064d6929b5ebdadd9d974aa835cfffda95c39f 100644 (file)
@@ -419,12 +419,6 @@ pub mod registers {
         FIFO = 1,
     }
 
-    impl From<Mode> for bool {
-        fn from(val: Mode) -> Self {
-            matches!(val, Mode::FIFO)
-        }
-    }
-
     #[bitsize(2)]
     #[derive(Clone, Copy, Debug, Eq, FromBits, PartialEq)]
     /// `WLEN` Word length, field of [Line Control register](LineControl).