Skip to content

Commit bf9987c

Browse files
committed
rust: pl011: simplify handling of the FIFO enabled bit in LCR
Use ==/!= instead of going through bool and xor. Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 6b4f7b0 commit bf9987c

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

rust/hw/char/pl011/src/device.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,7 @@ impl PL011State {
302302
Ok(LCR_H) => {
303303
let new_val: registers::LineControl = value.into();
304304
// Reset the FIFO state on FIFO enable or disable
305-
if bool::from(self.line_control.fifos_enabled())
306-
^ bool::from(new_val.fifos_enabled())
307-
{
305+
if self.line_control.fifos_enabled() != new_val.fifos_enabled() {
308306
self.reset_rx_fifo();
309307
self.reset_tx_fifo();
310308
}
@@ -497,7 +495,7 @@ impl PL011State {
497495

498496
#[inline]
499497
pub fn fifo_enabled(&self) -> bool {
500-
matches!(self.line_control.fifos_enabled(), registers::Mode::FIFO)
498+
self.line_control.fifos_enabled() == registers::Mode::FIFO
501499
}
502500

503501
#[inline]

rust/hw/char/pl011/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,6 @@ pub mod registers {
419419
FIFO = 1,
420420
}
421421

422-
impl From<Mode> for bool {
423-
fn from(val: Mode) -> Self {
424-
matches!(val, Mode::FIFO)
425-
}
426-
}
427-
428422
#[bitsize(2)]
429423
#[derive(Clone, Copy, Debug, Eq, FromBits, PartialEq)]
430424
/// `WLEN` Word length, field of [Line Control register](LineControl).

0 commit comments

Comments
 (0)